The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-14-2006
KenL KenL is offline
Registered User
  
 

Join Date: Oct 2006
Location: Ontario (Canada)
Posts: 2
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?
  #2 (permalink)  
Old 11-14-2006
tmarikle tmarikle is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2005
Posts: 683
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
of course I don't have your setup.sh script and I commented out your system calls to see what is happening but the parameter isn't remaining.
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
Uncomment the "#set -x" and set the shell show you what's going on.
  #3 (permalink)  
Old 11-15-2006
grial's Avatar
grial grial is offline Forum Advisor  
El UNIX es como un toro
  
 

Join Date: Jun 2006
Location: Madrid (Spain)
Posts: 531
Helo.
Is that the whole script? I mean, does it anything else appart from that? Notice that your script does not exit when there are no parameters. Change this:
Quote:
# Check parameters
if [ $# != 1 ]
then
echo "*E* Batch Queue parameter is missing"
else
into:
Code:
# Check parameters
if [ $# != 1 ]
then
   echo "*E* Batch Queue parameter is missing"
   exit 1
else
and let's see what happens. Check also your shell environment. Just give something like:
Code:
env | grep -i dayq
And check what it shows...
Regards.
  #4 (permalink)  
Old 11-15-2006
KenL KenL is offline
Registered User
  
 

Join Date: Oct 2006
Location: Ontario (Canada)
Posts: 2
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
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:05 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0