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" ]] 
echo $metrics_out 

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. 

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"


Post a Comment

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