shell script command
Hi All,
I am writing shell hotplug script,that get run when I insert the USB HD. But I am facing a problem,we have a proprietary command that is as below. cfg_write CIFSShares + If I run that command from busybox(console), sucessfully get run. If I give same command from hotplug script,that doesnt get run. I am suspecting that the "+" operater expecting operand. Even I tried below combinations in the script. cfg_write is app and CIFSShares, + are arguments. The script has the redirecting commands as below. #exec 1>/dev/consol #exec 2>/dev/consol 1)ret="`cfg_write CIFShares +`" 2)cfg_write "CIFSShares" "+" 3)cfg_write CIFSShares '+' 4)arg1=CIFSShares arg2="+" cfg_write $arg1 $arg2 5) echo "#!/bin/sh" > /tmp/cfg_write.sh echo "cfg_write CIFSShares +" >> /tmp/cfg_write.sh chmod 777 /tmp/cfg_write.sh ./tmp/cfg_write.sh With above combination I am not succeed. But If I uncomment the redirecting commands ( ex:exec 1>/dev/consol instead #exec 1>/dev/consol),no problem at all. my shell is busy box shell(sh). Please help out Thanks, harinath |
I'm more well versed in bash, but here are some suggestions:
- Enable debug within your script, for instance if you perform Code:
set -vx - More importantly would be the path variable from within the script, as well as where the executables that the script is running are located. Where is cfg_write? Is it located in that same directory? Then you may want to consider invoking it from within the script as following Code:
./cfg_write <followed by arguments> Code:
/bin/cfg_write Note also that even if you're invoking the executable from the directory where it is located, if your path variable does not have ".", a.k.a. DOT, a.k.a. the local directory as part of the path, then it will not consider binaries or scripts from that local directory, hence why you would use the first rendition utilizing ./<name. Next also note that the environment within scripts is not always the environment you expect, it depends how you are invoking the script. Since you're running it as part of a hotplug, then you are not manually executing it from a terminal window that you're sitting at, but instead from a potentially different environment. One trick here is to output your environment to a log file when the script runs Code:
/usr/bin/env > /home/mylogin/script.log |
Quote:
Quote:
in hotplug script? and/or "$PATH" variable differences. Start with something like: Code:
#!/bin/sh Substitute /path/to/ for the actual path: Code:
whereis cfg_write Code:
ret="`cfg_write CIFShares +`" Please use [code][/code] tags. |
Quote:
|
Hi All,
Thanks to you all. I tried with all your advises,not helpful so please find the script i am using and let me know if I am doing wrong over here. Code:
#!/bin/sh Thanks, Harinath |
All times are GMT -5. The time now is 12:19 PM. |