System Command dies even when command gets executed successfully


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting System Command dies even when command gets executed successfully
# 1  
Old 05-15-2011
Question System Command dies even when command gets executed successfully

Hi

I have created a perl script & running it using Linux machine. I want my script to die when system command is unsuccessful but script is dying even when system command gets executed successfully. Smilie
I am using the command below :-

system($cmd) || die "FAILED $!";
print "Hello";

Please help !!
# 2  
Old 05-15-2011
Well, it works for me fine. It prints the "Hello" on stdout

Code:
[ahamed@ahamed test]$ cat run
#!/usr/bin/perl

system($cmd) || die "FAILED $!";
print "Hello\n";

[ahamed@ahamed test]$ ./run
Hello

regards,
Ahamed
# 3  
Old 05-15-2011
Thanks for your reply Smilie
Actually I am firing a command on some other machine using remote shell (rsh) , so may be that's why it's not working for me.
Is there any other way to do the same?
I need to do rsh on various machines ....As I get different error messages on different machines so I also can't use the backtick operator to match the exit value of the command Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To check if the JAVA Program is successfully executed in sh shell scripting

Hi , I have written a shell script to call a java program say load_id.sh .This sh script indeed is executed implicitly in other sh script which calls 2 more sh scripts one by one. I need to check if the load_id.sh (which calls java program) is executed successfully only then continue with... (1 Reply)
Discussion started by: preema
1 Replies

2. UNIX for Dummies Questions & Answers

Set Command to output a log of every command executed in the script

Hi Guys, I like to output every command executed in the script to a file. I have tried set -x which does the same. But it is not giving the logs of the child script which is being called from my script. Is there any parameters in the Set command or someother way where i can see the log... (2 Replies)
Discussion started by: mac4rfree
2 Replies

3. Shell Programming and Scripting

Need to echo command successful if command is executed successfully

Hello, I have written a command n shell script : srvctl relocate service -d t1 -s s1 -i i1 -t t1 -f If the above command executes successfully without error I need to echo "Service relocated successfully and If it errors out I need to trap the errors in a file and also need to make... (1 Reply)
Discussion started by: Vishal_dba
1 Replies

4. HP-UX

Mailx command running successfully but no mails received.

Hi, I am working on a HP-UX box. Mailx command running successfully but no mails received. Here is what I am doing rocfm@comhp73 - mailx -s "subject" abc@gmail.com < abc.txt Null message body; hope that's ok rocfm@comhp73 - echo $? 0 rocfm@comhp73 - echo "something" | mailx -v -s... (1 Reply)
Discussion started by: Sunayna
1 Replies

5. Shell Programming and Scripting

script has been executed successfully or not??

Guys, How can we know whether a script has been executed successfully or not ? We dont have any log directories, and we are not given a chance to modify the script. Could someone help me out with this Thanks (2 Replies)
Discussion started by: bobby1015
2 Replies

6. Shell Programming and Scripting

How command is executed

as i have been new to unix can any one can tell,when be type a command on unix shell what processing it goes through before execution of it (1 Reply)
Discussion started by: shashank1311
1 Replies

7. Shell Programming and Scripting

Need help! command working ok when executed in command line, but fails when run inside a script!

Hi everyone, when executing this command in unix: echo "WM7 Fatal Alerts:", $(cat query1.txt) > a.csvIt works fine, but running this command in a shell script gives an error saying that there's a syntax error. here is content of my script: tdbsrvr$ vi hc.sh "hc.sh" 22 lines, 509... (4 Replies)
Discussion started by: 4dirk1
4 Replies

8. UNIX for Advanced & Expert Users

Script working successfully only when executed twice

Guys, i am facing a very strange issue, my code below does an ftp to server A and gets a file to Server B, once the file is in B an if condition is present to check if the pattern of the filename is ABC* then it has to be encrypted using OPENSSL as ABC.enc else if it of pattern 123* has to be... (3 Replies)
Discussion started by: meva
3 Replies

9. Cybersecurity

Help Required: Command to find IP address and command executed of a user

Hi, I am trying to write a script which would figure out who has run which command and their IP. As i dont have any clue as to which commands would do this job, i request some gurus to help me on this. Thanks Vishwas (2 Replies)
Discussion started by: loggedout
2 Replies

10. Solaris

Where we can get the logs for a command execution successfully?

Hi, How to get the logs for successfully executing of a solaris command? Where the logs will be stored? How to know that the commands is executed successfully or not? Thanks, Susi. (4 Replies)
Discussion started by: susinthaa
4 Replies
Login or Register to Ask a Question