![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Two Login's - Remember only one. | Cameron | Forum Support Area for Unregistered Users & Account Problems | 2 | 09-27-2007 10:04 PM |
| Invoke script depending on previous scripts | mpang_ | Shell Programming and Scripting | 0 | 06-26-2006 03:27 AM |
| remember last visited line in vim | spopuri | UNIX for Dummies Questions & Answers | 2 | 05-24-2006 01:27 PM |
| AWK--does anyone remember it | cnitadesigner | Shell Programming and Scripting | 2 | 12-06-2004 05:27 PM |
| It's been awhile...help me remember | catbad | Shell Programming and Scripting | 2 | 07-15-2002 04:48 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
scripts remember the previous parameter???
I have a simple script. I have tried this in Bourne, Korn and C shells in my AIX ...no luck
unset STARTQUEUE # Check parameters if [ $# != 1 ] then echo "*E* Batch Queue parameter is missing" else $BATCHQ/bin/setup.sh STARTQUEUE=$1 # If the queue doesn't exist, create it if [ ! -d "$QUEUES/$STARTQUEUE" ] ; then mkdir $QUEUES/$STARTQUEUE fi # If the queue log doesn't exist, create it if [ ! -f "$QUEUES/$STARTQUEUE/queue.log" ] ; then cp $QUEUES/flag.dat $QUEUES/$STARTQUEUE/queue.log fi # If the logs folder doesn't exist, create it if [ ! -d "$QUEUES/$STARTQUEUE/logs" ] ; then mkdir $QUEUES/$STARTQUEUE/logs fi # Check to see if the queue is already running if [ -f "$QUEUES/$STARTQUEUE/started.dat" ] then echo "*E* Batch Queue ($STARTQUEUE) is already running" else # Create a flag file to indicate the queue has started cp $QUEUES/flag.dat $QUEUES/$STARTQUEUE/started.dat echo "Batch Queue ($STARTQUEUE) started `date`" >> $QUEUES/STARTQUEUE/queue.log fi fi The problem is that once I run the script, $1 stays in memory (or where ever) and if I DO NOT supply the parameter the second time I run the script, it somehow remembers the script. for example: / $ startq *E* Batch Queue parameter is missing / $ starq dayq *E* Batch Queue (dayq) is already running / $ starq *E* Batch Queue (dayq) is already running Any ideas how to erase the value of $1 when I run the over and over? |
|
||||
|
Works for me.
Code:
./starq dayq ./starq[11]: /bin/setup.sh: not found Batch Queue (dayq) started Tue Nov 14 14:50:17 MST 2006 $ ./starq *E* Batch Queue parameter is missing $ ./starq dayq ./starq[11]: /bin/setup.sh: not found Batch Queue (dayq) started Tue Nov 14 14:50:38 MST 2006 $ ./starq *E* Batch Queue parameter is missing Code:
#! /usr/bin/ksh
unset STARTQUEUE
# Check parameters
#set -x
if [ $# != 1 ]
then
echo "*E* Batch Queue parameter is missing"
else
$BATCHQ/bin/setup.sh
STARTQUEUE=$1
# If the queue doesn't exist, create it
if [ ! -d "$QUEUES/$STARTQUEUE" ] ; then
:
#mkdir $QUEUES/$STARTQUEUE
fi
# If the queue log doesn't exist, create it
if [ ! -f "$QUEUES/$STARTQUEUE/queue.log" ] ; then
:
#cp $QUEUES/flag.dat $QUEUES/$STARTQUEUE/queue.log
fi
# If the logs folder doesn't exist, create it
if [ ! -d "$QUEUES/$STARTQUEUE/logs" ] ; then
:
#mkdir $QUEUES/$STARTQUEUE/logs
fi
# Check to see if the queue is already running
if [ -f "$QUEUES/$STARTQUEUE/started.dat" ]
then
echo "*E* Batch Queue ($STARTQUEUE) is already running"
else
# Create a flag file to indicate the queue has started
:
#cp $QUEUES/flag.dat $QUEUES/$STARTQUEUE/started.dat
echo "Batch Queue ($STARTQUEUE) started `date`"
#>> $QUEUES/STARTQUEUE/queue.log
fi
fi
set +x
|
|
||||
|
Ok that solved the problem.
I removed the contents of setup.sh and reduced it to only the lines that I needed and it now works. Thanks As for the EXIT. I used to have one, but when I ran the script from root...it logged me out of the system instead of the script. I changed it exit gracefully without an exit. Ken |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|