shell script problem

I wrote a shell script, which invokes another shell script, and reporting the error of: (Unable to access node /proc) and I cannot figure out why. I wish someone here can help me to find out how to get it working.

The cutdown version of the scripts are:

cmd1.sh

if [ $1 == 1 ]
then
cmdStr="./cmd2.sh pidin -P pterm mem"
else
cmdStr="./cmd2.sh sin -P pterm mem"
fi

$cmdStr &

cmd2.sh

i=0
for p in $*
do
param[$i]=$p
i=$(($i+1))
done

cmd=""
while [ x -lt $# ]
do
cmd=$cmd" "${param[$x]}
x=$(($x+1))
done
echo cmd is : $cmd

op $cmd

It appears that when I passed it with a ‘sin’ command, it is not happy; but works find for a ‘pidin’ command.

Any help is greatly appreciated.

Thanks

It seems the problem is the “&” after $cmdStr in cmd1.sh… I don’t know why exactly… it’s like “sin” cmd try to search via the network (but locally) if it runs in background… try to make sin -n <non_existing_node> and you get the same error msg but at that remote node…

btw, why are makeing it a bit complex, calling cmd2 from cmd1 and transversing all the parameters, etc…?

Isn’t enough to execute just your sin or pidin cmd… ?

Regards
JM

Hi Juanplacco,

Thank you to your response. As I mentioned in my original post, the cmd2.sh is a cutdown version of a more complicated script. This script can take any command line or script as its input parameter and perform profiling function on the execution output of that input command line or script.

This error result of sin has been bothering me for a long time and I was using pidin instead to try get the statistical result. But recently, I have other application that desperately need that sin working.

I wonder if you or someone reading this can come up with a work around.

Thanks

Do you still need to run cmd2 in background mode?

Good point. As you said, after I remove the &, it works magically. I guess I can live without running it in background mode at the moment.

The reason that I wanted to run it in background mode is I can use the same console to kill the script if necessary. But have it running is more important for me.

Thanks