Sunday, December 15, 2013

Converting a Solaris Shell Script to work on Linux

www.unixbabuforum.inI need to convert a Solaris Shell script to work on Linux. The Solaris script is using truss as follows: 

START_TIME=$(/usr/bin/truss /usr/bin/date 2>&1 | nawk -F= '/^time\(\)/ {gsub(/ /,"",$2);print $2}') 

END_TIME=$(/usr/bin/truss /usr/bin/date 2>&1 | nawk -F= '/^time\(\)/ {gsub(/ /,"",$2);print $2}') 

if [[ -n "$START_TIME" && -n "$END_TIME" ]] 
then 
metrics_out="$((END_TIME-START_TIME))|${RECORD_COUNT}" 
echo $metrics_out 
fi 

return 0 

I have read where the Linux command strace is the equivalent of the Solaris command truss, but I cannot seem to make the commands above work with strace

www.unixbabuforum.inTime difference. Please use below script. 

#!/bin/bash 
START=$(date +%s) 
# do something 
# start your script work here 
ls -R /etc > /tmp/x 
rm -f /tmp/x 
# your logic ends here 
END=$(date +%s) 
DIFF=$(( $END - $START )) 
echo "It took $DIFF seconds"

0 comments:

Post a Comment

 
Design by BABU | Dedicated to grandfather | welcome to BABU-UNIX-FORUM