LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Single Instance of Bash Script (https://www.linuxquestions.org/questions/programming-9/single-instance-of-bash-script-831683/)

catkin 10-04-2010 11:20 AM

What is the current script? There was a typo in [[ PID -eq MYPID ]] && continue which should have been [[ $PID -eq $MYPID ]] && continue.

konsolebox 10-05-2010 03:30 AM

@catkin No it's meant to be that way. They are just the same with integers. :)

catkin 10-05-2010 06:44 AM

Quote:

Originally Posted by konsolebox (Post 4118078)
@catkin No it's meant to be that way. They are just the same with integers. :)

Neat. How does that work? Is it that the presence of a numeric operator within the [[ ... ]] makes bash treat the logical expression as a numeric expression, in which the $ operator ($ means "value of") is implied?

konsolebox 10-06-2010 05:03 AM

Quote:

Originally Posted by catkin (Post 4118221)
Neat. How does that work? Is it that the presence of a numeric operator within the [[ ... ]] makes bash treat the logical expression as a numeric expression, in which the $ operator ($ means "value of") is implied?

Yup something like that. Maybe with -eq and the likes. That's really one of the greatest difference between test or [ and [[.

binbash 10-06-2010 08:37 AM

Quote:

Originally Posted by konsolebox (Post 4117182)
The script's only meant to run with bash. If sh.exe is your default shell, that might give a difference with operations.

well I am running it within bash
c:\cygwin\bin\bash.exe /cygdrive/c/scripts/singlei.sh $1 $2 $3 $4

but have noticed that sometimes it says

error in program=C:\cygwin\bin\sh.exe

and sometimes

error in program=C:\cygwin\bin\bash.exe

have sh.exe stackdumps in some folders and bash.exe stackdumps in other folders so I guess it is some cygwin behaviour

I still haven't really narrowed down what exactly leads to it 'locking it'

but a friend left me a note saying a number of blank (as they appear when queued anyway) bash windows had opened up and all of them were using some cpu and 7 lock files were in the folder - he said he left them open - but they were closed and only 1 lock file in the folder when I logged on so they must have exited at some point

though it seems that closing one of the windows causes them all to close and things to start working again when the script is run again


All times are GMT -5. The time now is 11:26 AM.