LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > SUSE / openSUSE
User Name
Password
SUSE / openSUSE This Forum is for the discussion of Suse Linux.

Notices


Reply
  Search this Thread
Old 06-21-2010, 10:27 AM   #1
s_linux
Member
 
Registered: Jul 2009
Posts: 83

Rep: Reputation: 15
IF command


Hi All,
I have a script
Quote:
# Call mail script to send an email
if [ -f /tmp/report.txt ]; then
/usr/local/scripts/mail.pl
sleep 10
rm /tmp/report.txt
else
exit
fi
What I need to do is, I want to check if file exists, if file exists call other script (mail.pl)and then delete the file (assuming mail.pl script executed). If file not exists just exit out of the script.

I'm not sure how I can see that other script execution completed or not before I delete the file even though I put sleep command.

And also it seems like its not that good, even though it is working. I wanted to see if we can write in more efficient way.
Any help appreciated.
 
Old 06-21-2010, 10:33 AM   #2
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
Try catching the return code from mail.pl, by checking $? right after the mail.pl executed.

Another option could be to check mail.pl's prints on standard output (stdout) or standard error (stderr), if it prints anything.

Or maybe you can start by explaining what mail.pl actually does?
 
Old 06-21-2010, 10:40 AM   #3
s_linux
Member
 
Registered: Jul 2009
Posts: 83

Original Poster
Rep: Reputation: 15
Thanks,
mail.pl script just sends an email. I can not add mail command in main script bcz it does not work. don't ask me why.

But my main concern is write the same script in efficient way.
Thanks
 
Old 06-21-2010, 10:47 AM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by s_linux View Post
Thanks,
mail.pl script just sends an email. I can not add mail command in main script bcz it does not work. don't ask me why.
OK--I won't ask--I'll just suggest that you figure out why the "mail" command does not work. Assuming that it works as expected in a real-time terminal session, then you really DO want to know why it does not work in a script.

Please no texting shorthand here----because
 
Old 06-21-2010, 10:51 AM   #5
s_linux
Member
 
Registered: Jul 2009
Posts: 83

Original Poster
Rep: Reputation: 15
Yes that will be the my next step to figure out why its not working.


Thanks
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash Command Line Editor, while typing run another command before executing current? gumaheru Linux - General 5 04-13-2010 11:21 AM
how to copy drive using dd and tee command parallely? source code of dd command mdfakkeer Linux - Software 1 02-10-2010 01:31 PM
URGENT! Is there any command to get a history command lines and time in SUSE Linux.? igsoper Linux - Software 5 06-25-2009 02:14 AM
LXer: The Linux Command Shell For Beginners: Fear Not The Command Line! LXer Syndicated Linux News 0 12-22-2008 06:30 PM
Translating windows pscp command to linux scp command help robward Linux - General 2 01-17-2008 06:02 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > SUSE / openSUSE

All times are GMT -5. The time now is 11:11 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration