Archive for June, 2009

(Mac OS X 10.4)Bug in

I had a long overdue for a post in this category as hectic work at the office kept me at bay. But there was an interesting find that had to be posted, for i strongly feel that solution for this trivial yet hard to identify bug would help all those users who are still on Tiger 10.4.X and here is the flash back …

Couple of months ago I was working on some shell scripts and was trying to get a PID of Console application running on Tiger 10.4.11 with the below command and to my amazement i didn’t get the process id at all even though was running !! After some struggle it came to behavior that was illogical, it never worked for the very first time i opened the terminal and then type the below command. Try executing different commands and then the below command would work fine. I tried many other options thinking some of my commands were wrong but with little success and neither did Google search helped. The same command was working like a charm on Leopard 10.5
PID=`ps -ax -o "pid" -o "command" | grep -i "/Applications/Utilities/" | grep -v grep | awk '{print $1}'`
echo $PID

Days went by and was still not able to figure out why the above problem was happening. But then i discovered a strange thing when i expanded the terminal . Check out the picture below,

Weird Space

If you open a new terminal, window resolution will be by default 80×24. That is it has 80 columns. so when you type the above ps -ax command, the output of this command will stretch to columns more than 80. So i probably think there is bug in on Tiger. If you expand the terminal for a bigger view after the ps -ax command, most of the output will be truncated and hence i wasn’t getting the PID. Phew … that’s a weird find but how about the fix?

PID=`ps -ax -w -w -o "pid" -o "command" | grep -i "/Applications/Utilities/" | grep -v grep | awk '{print $1}'`
echo $PID

see those “-w ” twice .. well if you man ps command you will know it. After this small tweak in the script everything works fine !

man ps

— Go Green, Save a Tree —


June 25, 2009 at 12:23 pm Leave a comment

June 2009
« May   Aug »