![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| "find command" to find the files in the current directories but not in the "subdir" | swamymns | Shell Programming and Scripting | 9 | 07-22-2008 12:23 PM |
| Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" | Lokesha | UNIX for Dummies Questions & Answers | 4 | 12-20-2007 01:52 AM |
| Unix "at" / "Cron" Command New Problem...Need help | Mohanraj | UNIX for Dummies Questions & Answers | 3 | 01-26-2006 08:08 PM |
| Breaking input with "read" command | vino | Shell Programming and Scripting | 2 | 08-04-2005 01:10 PM |
| how to request a "read" or "delivered" receipt for mails | plelie2 | Shell Programming and Scripting | 1 | 08-06-2002 04:26 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hello there. I'm trying do make a script capable of verifying if a given script is running at the moment in the environment, and if does, forbid it to execute. So, I've coded this so far: Code:
#!/bin/ksh
set CUR_SHELL="/bin/ksh"
set V1="VAR1"
set V2="VAR2"
ps -e -o args | grep "$CUR_SHELL $1" | tr -s " " | cut -d" " -f1 |
while read -r V1 V2
do
if [ "$V1" = "$CUR_SHELL" ]; then
echo "Error - Program is already running."
echo "V1 -> $V1"
exit 1
fi
done
echo "V1 -> $V1"
echo "V2 -> $V2"
if [ -z "$V1" ]; then
echo "V1 IS NULL"
fi
I was trying to encapsulate the ps and its pipes into a variable, then to use it like while read $COMMAND V1 V2 (the second variable exists only for testing purposes) or while read .... do done < $COMMAND But I got into a endless loop. Also, I got into the first if and the variable V1 printed out was displaying NULL... Does anyone have any suggestion, tip or corrections to this script ? Thanks in advance, 435 Gavea - bRaZiL - thE hElL iS herE !!! ![]() added code tags for readability --oombera Last edited by oombera; 02-21-2004 at 02:18 AM.. |
|
||||
|
Thanks, google
Well, I've heard about some solutions using a temporary file as well, but
my "boss" said to avoid this option if I can. So I'm trying to figure out a different solution... But I didn't thaught about using the PID ... it may be a good point... Thanks anyway ! |
|
|||||
|
Quote:
var="string" will set $var to the value "string". On the other hand, set var=string does not affect a variable called var. Instead it clobbers the arguments and sets $1 to the value "var=string". Try it, set var="string" echo $var echo $1 |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|