|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
1200+ fellow developers rate and compare features of the top IDEs, like Visual Studio, Eclipse, RAD, Delphi and others, across 13 categories. Enjoy this FREE Download of the IDE User Satisfaction Study by Evans Data Corporation. Download Now!
|
|
#1
|
|||
|
|||
|
Need some help in unix scripting
Basically there are three scripts, for example walk.sh, stand.sh and sleep.sh
and the walk.sh should not run when either stand.sh or sleep.sh is running. for this I have put in walk.sh as below: #!/bin/sh sleeppid=`ps -aef | grep -i "sleep.sh" | grep -v grep | awk '{print $2}'` standpid=`ps -aef | grep -i "stand.sh" | grep -v grep | awk '{print $2}'` if [ ${sleeppid} -gt 1 ] || [ ${standpid} -gt 1 ] then echo "sleep or stand process already started" exit else echo "walk process can be started" sleep 120 fi when I ran the walk.sh script I got below error message, but when sleep or stand scripts are running, and when I tried to start walk script I got correct message as "sleep or stand process already started" I tried hard I did't able to correct this walk.sh script, It is saying about test argument , which I dont understand please help as early as possible: ======================================= ksh -x walk.sh + + ps -aef + grep -i sleep.sh + awk {print $2} + grep -v grep sleeppid= + + ps -aef + grep -i stand.sh + awk {print $2} + grep -v grep standpid=23104 + [ -gt 1 ] walk.sh[5]: test: argument expected + [ 23104 -gt 1 ] + echo sleep or stand process already started sleep or stand process already started + exit |
|
#2
|
|||
|
|||
|
Use double quotres around the variables in the single bracket test.
if [ "${sleeppid}" -gt 1 ] || [ "${standpid}" -gt 1 ] |
|
#3
|
|||
|
|||
|
Help
I have been trying to get this program to work but just can not get it right?Write a shell script named showparms which will disp1ay each positional parameter from the shell command line (including $0), as well as the argument count $# and the entire set of command line parameters $@. Your script should display as many positional parameters as there are arguments, but if there are more than nine arguments on the command line display only the first nine positional parameters ($1 through $9). In either case, $@ should show all of the arguments. Be sure to include appropriate comments in your script so I will know what your script is doing. Each parameter should be displayed on a separate line which shows the parameter name and has the parameter value delimited by the angle brackets < and > so that it will be possible to see an argument which consists of a null string () or a blank space or spaces ( ). As an example:
$ showparms 3 a b c Dec 15 Your ouput should be like this: $# = 5 $0 = <showparms> $1 = <3> $2 = < > $3 = <a b c> $4 = <> $5 = <Dec 15> $@ = <3 a b c Dec 15> The $@ is a list of all arguments. When displaying the value for $@, make sure you can account for all of the space characters which are displayed. There should not be too few or too many. In the example above, there is one space between each of the command line arguments, one additional space for the parameter $2 since it is and no additional spaces for the parameter $4 since it is . Execute your script with a command line of fewer than nine arguments and a command line of more than nine arguments. When there are fewer than nine arguments you should only display as many positional parameters as there are arguments. For example, if there are four arguments you should not display the $5 argument. IF there are more than nine arguments then you should not try to display $10 since there is no such thing! if you can help i would greatly appreciate it Thanks |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Need some help in unix scripting |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|