Intro to Unix/Linux BASH Script 1. Here is another short BASH script. Use nano o
ID: 3705007 • Letter: I
Question
Intro to Unix/Linux
BASH Script
1. Here is another short BASH script. Use nano or some other simple
editor to type it in. This script demonstrates how to use the
/bin/mail program to send email and messages through the Internet.
/bin/mail needs to send a file so the mailme program begins by asking
you to type a few lines and constructing a file called "themessage"
The mailme script then sends this message to your email address on
Vader, or if you provide it, another email address.
#mailme
#Send a short message to an email address
#Uses an email address from the command line if it's there,
# otherwise constructs an email address from your LOGNAME
#Nazaire Biscoe, Spring 2018
if [ "$1" ]
then
myaddrs=$1
else
myaddrs="${LOGNAME}@vader.aacc.edu"
fi
echo "Message sent $(date)" > themessage # this creates the message file
echo "Please type a short message (3 lines max) "
for i in 1 2 3
do
read line
echo $line >> themessage # this adds up to 3 lines to the message file
done
/bin/mail -s "A short message" $myaddrs < themessage
Run this script to make sure it works. Each time you
run it use the command
alpine
to check your mail on Vader. Press i to see the index of your messages,
cursor down and press Enter to select one. Press d to delete a message
and q to end the Alpine email client.
2. Try using the mailme script to send a message to your cell phone
using the address:
nnnnnnnnnn@vtext.com (this is for Verizon cell phones)
(it's different for other providers)
where the 10 ns represent your cell phone number.
Rev. 2018-3-19
Explanation / Answer
#!/bin/sh
if [ "$1" ]
then
myaddrs=$1
else
myaddrs="nnnnnnnnnn@vtext.com"
fi
echo "Message sent $(date)" > themessage.txt # this creates the message file
echo "Please type a short message (3 lines max)"
for i in 1 2 3
do
read line
echo $line >> themessage.txt # this adds up to 3 lines to the message file
done
/bin/mail -s "A short message" $myaddrs < themessage.txt
echo "Message has been appended to "themessage.txt" file."
2. It is not possible to send a message to phone using script. This requirement has to be done from using any technology like java, php, ruby etc..I hope this will helps.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.