Forgive my newness...I am composing a small script to execute multiple times on several boxes. The local box works fine, but when it ssh's into box2, the "for" command doesn't work...it's only pulling the last date ($sun).
Code:
#!/bin/bash
# This will ask for input on which sa.* files you want to process
# then issue a sar command against them, output to /tmp/bill.##
# then email them to specified recipients
# Instructions
echo "Put in the date for each day in question to process those files..."
############# USER INPUTS VARIBLES HERE #################
# Variables for day of week
printf "Mon: "
read mon
printf "Tues: "
read tues
printf "Wed: "
read wed
printf "Thurs: "
read thurs
printf "Fri: "
read fri
printf "Sat: "
read sat
printf "Sun: "
read sun
############### THIS WORKS FINE ########################
# Take date variables and process files through sar to /tmp/bill.dd
for file in $mon $tues $wed $thurs $fri $sat $sun;
do echo "--- Processing sa$file ---";
sar -uf /var/adm/sa/sa$file > /tmp/bill.$file;
done
# Email the files
(/usr/bin/unix2dos -437 /tmp/bill.$mon | /usr/bin/uuencode bill.$mon;
/usr/bin/unix2dos -437 /tmp/bill.$tues | /usr/bin/uuencode bill.$tues;
/usr/bin/unix2dos -437 /tmp/bill.$wed | /usr/bin/uuencode bill.$wed;
/usr/bin/unix2dos -437 /tmp/bill.$thurs | /usr/bin/uuencode bill.$thurs;
/usr/bin/unix2dos -437 /tmp/bill.$fri | /usr/bin/uuencode bill.$fri ;
/usr/bin/unix2dos -437 /tmp/bill.$sat | /usr/bin/uuencode bill.$sat ;
/usr/bin/unix2dos -437 /tmp/bill.$sun | /usr/bin/uuencode bill.$sun) > deleteme.txt
######### HAVING PROBLEMS BELOW ###############
# ssh to 2ndserver
/usr/bin/ssh -l bjones 2ndserver "
for file in $mon $tues $wed $thurs $fri $sat $sun;
do echo "--- Processing sa$file ---";
sar -uf /var/adm/sa/sa$file > /tmp/bill.$file;
done
(/usr/bin/unix2dos -437 /tmp/bill.$mon | /usr/bin/uuencode bill.$mon;
/usr/bin/unix2dos -437 /tmp/bill.$tues | /usr/bin/uuencode bill.$tues;
/usr/bin/unix2dos -437 /tmp/bill.$wed | /usr/bin/uuencode bill.$wed;
/usr/bin/unix2dos -437 /tmp/bill.$thurs | /usr/bin/uuencode bill.$thurs;
/usr/bin/unix2dos -437 /tmp/bill.$fri | /usr/bin/uuencode bill.$fri ;
/usr/bin/unix2dos -437 /tmp/bill.$sat | /usr/bin/uuencode bill.$sat ;
/usr/bin/unix2dos -437 /tmp/bill.$sun | /usr/bin/uuencode bill.$sun) > deleteme.txt"
exit 0