Dr Small
April 21st, 2008, 01:50 AM
I have written a very short script in haste, and basically I want to pipe other commands into it. Whatever I pipe into it, I want to be able to nab that command and add it as a variable to my script.
Here is the current script:
#!/bin/bash
to="drsmall@mycroftserver.homelinux.org"
subject="Server Emergency"
message=$(echo "Mycroft Server Emergency.\n\nLast command:\n"$0 "\n\n\nReason:\n"$1)
echo -e $message | mail -s "$subject" $to
I have $0 in there for the script name, but when I get the email, in tells me the location of my mailer script, instead of the command I piped into it.
So the basic question, how can I read the command (not the stdin) in my script that I piped through it?
Dr Small
Here is the current script:
#!/bin/bash
to="drsmall@mycroftserver.homelinux.org"
subject="Server Emergency"
message=$(echo "Mycroft Server Emergency.\n\nLast command:\n"$0 "\n\n\nReason:\n"$1)
echo -e $message | mail -s "$subject" $to
I have $0 in there for the script name, but when I get the email, in tells me the location of my mailer script, instead of the command I piped into it.
So the basic question, how can I read the command (not the stdin) in my script that I piped through it?
Dr Small