Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scripting help required

Status
Not open for further replies.

pfildes

Programmer
Jun 17, 2004
54
GB
Can anybody please help with the following script source code?

I have a script which is executed every 15 mins via a Crontab entry. In the script I set a counter initially to zero. If a particular file exists, I read the counter value stored. If it equals 3 I set it to zero. If the counter is zero then I display a message. I then increment the counter and write it to the log file. This, hopefully, will mean a message every 1hr.

When I try to run the script I get the following error message;
[red][0: not found[/red]

which refers to the line in the following source code indicated as "<--- Error"

Code:
    integer AI_NUM=0
    #if [ -f $AI_LOG_FILE ]; then
    #    AI_NUM=`cat $AI_LOG_FILE`
    #    if [$AI_NUM -eq 3]; then
    #        AI_NUM=0
    #    fi
    #fi
        
    if [$AI_NUM -eq 0]; then   <------ Error!!
        echo "My Message"
    fi
    echo $AI_NUM + 1 > $AI_LOG_FILE
 
You need some white spaces on the if statements:

Code:
[b]    if [ $AI_NUM -eq 0 ]; then [/b]

Note the spaces after [ and before ]

Add a little color to your PUTTY terminal: faq52-6627
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top