cant get the right exit message


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting cant get the right exit message
# 1  
Old 02-18-2005
cant get the right exit message

#!/bin/ksh
application task run command //returns 0 if successful
if [$? eq 0]; then echo "Ran Fine"
else echo "Didnt run"
fi


When I run the script, here is the output
Status code = 0
ksh: [0: not found.
Job didnt run


any suggestions?
# 2  
Old 02-18-2005
Code:
pwd
if [ $? -eq 0 ]; then echo "Ran Fine"
else echo "Didnt run"
fi

# 3  
Old 02-18-2005
I still get the same error. Why do we need to put hyphen infront of operator?

script executed
#!/bin/ksh
application task run command //returns 0 if successful
if [$? -eq 0]; then echo "Ran Fine"
else echo "Didnt run"
fi


ouput:
Status code = 0
ksh: [0: not found.
Didnt run
# 4  
Old 02-18-2005
You are missing spaces after the "[" and preceeding the "]". This is the required syntax.

Please look carefully at the previous response.
Code:
if [ $? -eq 0 ]; then echo "Ran Fine"
else echo "Didnt run"
fi

Quote:
Why do we need to put hyphen infront of operator?
You'll have to ask the folks who designed the shell on this question. It's just simply required.

Thomas
# 5  
Old 02-18-2005
Thanks Guys Smilie

hyphen was needed before 'eq' since the operands were numericals
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need the difference between exit 1 & exit 7

Hi In one of the script I am seeing some thing like exit 7,exit 1,exit 2,exit 3,exit 9,exit6.What is the difference between all of this exit.Can anyone help here please (3 Replies)
Discussion started by: ginrkf
3 Replies

2. UNIX and Linux Applications

Ssmtp -t < /path/to/the/message.txt (How to format message.txt for html email)

ssmtp has been running well under Kubuntu 12.04.1 for plain text messages. I would like to send html messages with ssmtp -t < /path/to/the/message.txt, but I cannot seem to get the message.txt file properly formatted. I have tried various charsets, Content-Transfer-Encoding, rearranging the... (0 Replies)
Discussion started by: Ronald B
0 Replies

3. Programming

[XQuery] How to Convert from JSON Message to XML Message with XQuery

Hi guys, I'm in a job of converting a restful webservice to soap. Tool for convertation uses XQuery. Now i need to convert a message like this: { "firstName": "John", "midName": null, "lastName": "Smith", "married": false, "address": { "streetAddress": "21 2nd... (5 Replies)
Discussion started by: tien86
5 Replies

4. Shell Programming and Scripting

RE: exit value

I am running HP-UX & ksh I have several validation programs that scan log files for error messages. One of these files scan 3 diff files, thus I have the exit value in a variable and depending on which log-file I am scanning the value changes. I am not getting the value I expect but a... (1 Reply)
Discussion started by: vslewis
1 Replies

5. Programming

How to limit max no of message in a posix message queue

Hii can anyone pls tell how to limit the max no of message in a posix message queue. I have made changes in proc/sys/fs/mqueue/msg_max But still whenever i try to read the value of max. message in the queue using attr.mq_curmsgs (where struct mq_attr attr) its giving the default value as 10.... (0 Replies)
Discussion started by: mohit3884
0 Replies

6. UNIX for Dummies Questions & Answers

what is meaning of exit(0) and exit(1)

can u tell me what is the meaning of exit(0),exit(1),exit(2) what is diff amonng these. Amit (1 Reply)
Discussion started by: amitpansuria
1 Replies

7. Shell Programming and Scripting

exit 2

Hi even though I use exit in my first scripts, I am not sure exactly about exit codes.I know there is a relation between return and exit codes, exit 0 means it returned a 0 to indicate there is no error at the end of this point. But what does it mean: exit 1 , probably there was an error, OK... (2 Replies)
Discussion started by: xramm
2 Replies

8. Programming

exit(0) versus exit(1)

What is the difference between using exit(0) and exit(1) to exit a program? Which should I use? (9 Replies)
Discussion started by: enuenu
9 Replies

9. Shell Programming and Scripting

exit

Hi all, I am confused about When and where to use exit 0 and exit 1 ... Thanks (2 Replies)
Discussion started by: dhananjaysk
2 Replies

10. UNIX for Dummies Questions & Answers

Where can I find a list of exit codes? (Exit code 64)

I'm receiving an exit code 64 in our batch scheduler (BMC product control-m) executing a PERL script on UX-HP. Can you tell me where I can find a list of exit codes and their meaning. I'm assuming the exit code is from the Unix operating system not PERL. (3 Replies)
Discussion started by: jkuchar747
3 Replies
Login or Register to Ask a Question