How to return a message after command runs?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to return a message after command runs?
# 1  
Old 02-14-2013
How to return a message after command runs?

I have a script like this:

Code:
echo "enter filername in lowercase"
                read -e filername exec 2>&1
                echo "type the start date in format MM/DD/YYYY"
                read -e startdate exec 2>&1
                echo "enter the end date in format MM/DD/YYYY"
                read -e enddate exec 2>&1
                echo "please enter the path of file"
                read -e filepath exec 2>&1
[ $(echo $filepath | egrep -c '^\/*\/.*[\/]$') -ne 0 ] && echo " enter path without trailing slash" && read filepath
command=`/local/mnt/script.host.pl -client=$filername -start=$startdate -end=$enddate -show_files -filename=$filepath\
|gawk '{print $1, $11}'  |grep -v HOSTNAME | grep -vi Totals |uniq`
echo $command; if [[ "$command" == "No" ]]; then echo "yes";fi

I am trying to get it to return "yes" but all I get is no output

The command does actually return the word No. So I am trying to get it to echo "yes."

Last edited by newbie2010; 02-14-2013 at 02:54 PM..
# 2  
Old 02-14-2013
You get no output, at all? Something in that huge pipe-chain is messing up.

What does
Code:
/local/mnt/script.host.pl -client=$filername -start=$startdate -end=$enddate -show_files -filename=$filepath

print, and what output do you want from it?
# 3  
Old 02-14-2013
The command returns data when there is data. However, when it does not have data, it just prints No. I was trying to run a test to see if I could have the script produce a customer message, like "There is no data, try another date." I am sorry I put echo "yes" in the script, for this is deceiving. I really wanted it to print out a message such as "there is no data." I can't get it to print any customer message at this point, it just prints "No."

---------- Post updated at 03:14 PM ---------- Previous update was at 03:10 PM ----------

I think I have found the problem. Looks like part of the script was truncated when I was testing and I need to add the lines and retest it.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script runs but does not execute rm -rf command

Hi! First off I'm no bin/bash script writer! :( I can make heads and tales of it from the php experience I have and that's all. Now I managed to piece this script together to go look at directory and remove files that are +60 days. It's finding the files but its not removing them. I... (11 Replies)
Discussion started by: MrBiggz
11 Replies

2. Shell Programming and Scripting

Grep: Return a user message when no hits

I have ASCII files to parse that 48 hours old or more ; I can identify them like so find . -name "FILE*TXT" -mtime +1 -exec ls -ltas '{}' ';' Some files have a list of hardware errors (we test electronic components), some have none. If the file name has no errors, I still want to... (3 Replies)
Discussion started by: alan
3 Replies

3. Shell Programming and Scripting

How would you return how long a script runs for?

When running a ksh script, how would you time how long it took the script ran for? Is there a command that can capture this? (1 Reply)
Discussion started by: Jazmania
1 Replies

4. UNIX for Dummies Questions & Answers

Return mail message

Hi I would like to know how interpret line by line a return mail message sent by unix mailer-daemon (2 Replies)
Discussion started by: alcvrjo
2 Replies

5. UNIX for Dummies Questions & Answers

to pick up the Return Code ( RC) from the mailx command and return it to SAS uisng 's

Hi All, Can anyone please let me know the syntax / how to pick up the Return Code ( RC) from the mailx command and return it to SAS uisng 'system()' function and '${?}'. I am in a process to send the mail automatically with an attachment to bulk users. I have used 'Mailx' and 'Unencode'... (0 Replies)
Discussion started by: manas6
0 Replies

6. Shell Programming and Scripting

command runs, no output

I have a script that searches for specific information from log files. #!/bin/sh sed -n '/*C/,/END/p' /sn/log/OMlog* > crit.out sed -n '/REPT INITIALIZATION/,/err:/p' /sn/log/OMlog* > switchcc.out ./start.awk /sn/log/OMlog* > ARs.out ./end.awk /sn/log/OMlog* > ARe.out cat crit.out... (1 Reply)
Discussion started by: grinds
1 Replies

7. Shell Programming and Scripting

Return a message when a file is not found

Hi there, I am writing a script to look for tmp log files that have not been access within the last 10 days. I am using the follwing command within the script: find /var/tmp -name *log -atime -9 ¦xargs What I would like to be able to do would be to display a message if there is no... (3 Replies)
Discussion started by: lodey
3 Replies

8. Shell Programming and Scripting

Return status of all previous runs

hi, I set the crontab to execute script A every 5 minutes from 9:00 am to 4:00 pm everyday, now at 12:00am I want to run another script if and only if all the previous runs of script A return OK, can anyone tell me how it could be done? thank you very very much! (4 Replies)
Discussion started by: mpang_
4 Replies
Login or Register to Ask a Question