Visit Our UNIX and Linux User Community


shell script result to file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting shell script result to file
# 1  
Old 07-21-2009
shell script result to file

Since I'm not an expert in shell scripting, I have question on sending script result to file. I have script like this...

if condition=0: then
echo "service is not running" | mail -s "Server Status" uname@companyname
fi
sleep 10
if configtion=1: then
echo "service is not running" | mail -s "Server Status" uname@companyname
fi

else
echo "service is running" | mail -s "Server Status" uname@companyname
fi

script is working fine but getting 3 mails from the server.

Instead sending 3 emails, I want to put all 3 in 1 file, send an email with attached file. Any idea.

Thanks
# 2  
Old 07-21-2009
Before sending mail, put all your statements into one file and then cat the file. Try the following.....

if condition=0: then
echo "service is not running" > Result
fi
sleep 10

if configtion=1: then
echo "service is not running" >> Result
fi
else
echo "service is running" >> Result
fi


mailx -s "SUBJECT" uname@companyname << !END_OF_MSG

`cat Result`

!END_OF_MSG
# 3  
Old 07-21-2009
Thanks for the quick reply.

mailx -s "SUBJECT" uname@companyname << !END_OF_MSG

`cat Result`

!END_OF_MSG

when i try this, I got `cat Result` in the mail eventhough there is file.

I tried this...

cat Result mailx -s "SUBJECT" uname@companyname << !END_OF_MSG

then i dont see anything in the mail. but when i ran just out side the script, it works fine.

Any idea. Thanks

---------- Post updated at 10:55 AM ---------- Previous update was at 10:23 AM ----------

it works fine. I think it was my mistake.

to make it just look good in the email, i want to have as it is in the file (one result in one line). But in the email I see all line are combined. Can we do it seperate line in the email. Thanks
# 4  
Old 07-21-2009
These are left sloping quotes , not single quotes.

Code:
`cat Result`


Previous Thread | Next Thread
Test Your Knowledge in Computers #502
Difficulty: Medium
If a function uses a particular process or algorithm such as a Fast Fourier Transform to perform an operation, it would not be appropriate to document it in a series of comments in the source code.
True or False?

10 More Discussions You Might Find Interesting

1. Programming

Query result from shell script

Hi, I wrote the below script to get the query result from a Syabase DB. isql -s -U **** -P **** SYBASE SERVERNAME USE ***(Database name in Sybase) @command.sql But im not getting the output. Can anyone help me on this (2 Replies)
Discussion started by: rohan G
2 Replies

2. Shell Programming and Scripting

Executing the result of a program as a shell script

I have a program that returns a shell script and I want to execute the script. I'll use cat in my simple example, but wget is an example that is feasible. $ # First setup a script $ echo "ls > df" > simple $ # "cat simple" is now a program that returns a script $ cat simple ls df $ ... (3 Replies)
Discussion started by: kopite
3 Replies

3. Shell Programming and Scripting

shell script - unexpected result

I hv a file --am executing a script which is giving me unexpected results COntents of file: f1 CMT_AP1_CONT:/opt/sybase/syboc125:150:ASE12_5::Y:UX: CMT_AP1:/opt/sybase/syboc125:150:ASE12_5::Y:UX f1.tmp CMT_AP1_CONT:/opt/sybase/syboc125:150:ASE12_5::Y:UX:... (2 Replies)
Discussion started by: rajashekar.y
2 Replies

4. Shell Programming and Scripting

A function in shell script,how can i get the right result

there is a directory /data/users/osa/psidp/dmp/files/cimdir ,it have some subdirectories ,and also the subdirectoriy have it's subdirectoriis. I want to get all the leaf nodes of the directory path . but the result of the script is wrong ,how can i get the right result somebody who can help me... (3 Replies)
Discussion started by: fw0037
3 Replies

5. Shell Programming and Scripting

a function in shell script,how can i get the right result

there is a directory /data/users/osa/psidp/dmp/files/cimdir ,it have some subdirectories ,and also the subdirectoriy have it's subdirectoriis. I want to get all the leaf nodes of the directory path . but the result of the script is wrong ,how can i get the right result somebody who can... (1 Reply)
Discussion started by: fw0037
1 Replies

6. Homework & Coursework Questions

A function in shell script,how can i get the right result

there is a directory /data/users/osa/psidp/dmp/files/cimdir ,it have some subdirectories ,and also the subdirectoriy have it's subdirectoriis. I want to get all the leaf nodes of the directory path . but the result of the script is wrong ,how can i get the right result somebody who can help... (1 Reply)
Discussion started by: fw0037
1 Replies

7. Shell Programming and Scripting

How to get and process mysql result set in shell script

Hi All, I am in a problem here is the description, Actually in my shell script i am firing a mysql query which returns multiple records and i have to process each record one by one. So could any one please suggest me how to solve my problem? Thanks in Advance Ashok Sharma (4 Replies)
Discussion started by: ashok1979
4 Replies

8. Shell Programming and Scripting

get result from database into shell script

hi, I have a script that will logon to a database siebel and do the select query and then get the result in command prompt of unix.Below the script. #!/bin/ksh . $HOME/conf/systemProperties/EnvSetup.properties #set -x while read i do echo $i connect1=`sqlplus -silent... (1 Reply)
Discussion started by: ali560045
1 Replies

9. AIX

The shell script is not returning proper result

Can anybody pls look into this script and tell me where I went wrong. After running this script, it is showing like "Trying to overlay current working directory ABORT!!!" :-( ARGCNT=$# if then echo "Two parameters are needed for this shell " echo "Please try again with... (1 Reply)
Discussion started by: clnsharma123
1 Replies

10. Shell Programming and Scripting

Could any one tell me how to do get result in fraction in shell script

Could any one tell me how to do get result in fraction in shell script. I am using expr for division of 2 number but it is giving Quitent. I need it in full fraction value. please helpp. how to do it using "dc" or "bc" (5 Replies)
Discussion started by: Neerajjaiswal
5 Replies

Featured Tech Videos