script question
Slackrat
tlug-MOdoAOVCFFcswetKESUqMA at public.gmane.org
Mon Jan 21 21:11:05 UTC 2008
jim a écrit profondement:
| If I am writing a script and there is a command to run a program in the
| script that accepts a yes or no answer how do I supply that answer in
| the script?
| Thanks,
| Jim
#!/bin/bash
echo -n "Enter yes or no > "
read yesno
echo "yesno is $yesno"
if [ $yesno = "yes" ] ; then
echo "You input yes"
# do something - here get uptime
let upSeconds="$(awk '{ print $1 }' /proc/uptime | cut -f1 -d ".")"
let secs=$((${upSeconds}%60))
let mins=$((${upSeconds}/60%60))
let hours=$((${upSeconds}/3600%24))
let days=$((${upSeconds}/86400))
if [ "${days}" -ne "0" ]
then
echo -n "${days} days"
fi
echo -n " ${hours}:${mins}"
else
# do something else - here just echo response
echo "You input no"
fi
--
SlackRat - 4Q to Reply
--
The Toronto Linux Users Group. Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists
More information about the Legacy
mailing list