Shell script
Hi All,
I was trying to write a script and was trying to pass one of the variable as a file name in the script but unfortunately it is not working When i am trying to run the file manually it is working (a blank file with unknown subject line is getting created) Can anyone please help me Below is the script echo -e Message:$2 \ Device:$3 \ Category:$4 \ ErrorCondition:$1 \ Generatedat:$5 >> /tmp/warning.$(date +%Y%m%d-%H%M%S%s).txt |
It looks ok to me...
Can you provide us with more context i.e. the whole script and the variable values if not confidential? NB: you shoud probably use this instead: Code:
echo "Message:$2 Device:$3 Category:$4 ErrorCondition:$1 Generatedat:$5" >>/tmp/warning.$(date +%Y%m%d-%H%M%S%s).txt |
Quote:
Even after removing the -e we are unable to run the script. My exact requirement is I have a NMS tool (Application Manager) and whenever a alert is raised i will be calling a script and in that script i will be passing arguments which are as below $1 as message of the alert $2 Severity of the alert $3 OID . . . $6 eventid . Here my problem is when i am calling the script a file should be created with eventid script i configured as echo -e "Message:$2 Device:$3 Category:$4 ErrorCondition:$1 Generatedat:$5" >>/tmp/$6 output file to be created as In tmp folder file should be created as eventid This is what i am trying to achieve |
^ You mean that you don't get a new /tmp/{eventid} file after your script has run?
By the way, you should use ">>/tmp/$6" (with double quotes) and you don't need -e echo switch in your instruction (as you don't use any backslash anymore) |
No, the >> is a redirection operator and must not be in quotes!
>> "/tmp/$6" or >> /tmp/"$6" is okay. It's good to have every $X in the script within double-quotes. Further, I recommend a certain file extension. For example >> /tmp/"$6".event Then later you can do operations with /tmp/*.event |
^ Of course I meant >>"/tmp/$6", not ">>/tmp/$6".
Thanks for the correction ;) |
Quote:
Could you please show an exact example (contrive the information if sensitive) of calling your script including a listing of the file location before and after and any received messages |
Re: "grail"'s suggestion...
Take a look at the script(1) command before you collect your information. Saves a lot of cutting and pasting.
Code:
$ script session.log For example: Code:
$ script session.log HTH... |
All times are GMT -5. The time now is 10:07 AM. |