Hello Guys
I need some help with my script
I'm not very good at this, hope you can point me in the right direction.
My idea, to write a file with some router commands and use it on a script for me to run on a demand basis, ( or added to the cron, if I get it to work).
The below script works, but the output is being multiply by the number of commands, for example:
cat files/commands
sh ver
sh hard
sh env
SCRIPT
~~~~~~~~~~~~~~~~~~~
#!/usr/bin/ksh
sed -n '1p' files/commands > files/temp1
sed -n '2p' files/commands > files/temp2
sed -n '3p' files/commands > files/temp3
sed -n '4p' files/commands > files/temp4
sed -n '5p' files/commands > files/temp5
sed -n '6p' files/commands > files/temp6
sed -n '7p' files/commands > files/temp7
sed -n '8p' files/commands > files/temp8
sed -n '9p' files/commands > files/temp9
sed -n '10p' files/commands > files/temp10
comm1=$(cat files/temp1)
comm2=$(cat files/temp2)
comm3=$(cat files/temp3)
comm4=$(cat files/temp4)
comm5=$(cat files/temp5)
comm6=$(cat files/temp6)
comm7=$(cat files/temp7)
comm8=$(cat files/temp8)
comm9=$(cat files/temp9)
comm10=$(cat files/temp10)
for router in user@metis
do
print
echo router $router
(sleep 5
echo password
echo $comm1
sleep 5
echo $comm2
sleep 5
echo $comm3
sleep 5
echo $comm4
sleep 5
echo $comm5
sleep 5
echo $comm6
sleep 5
echo $comm7
sleep 5
echo $comm8
sleep 5
echo $comm9
sleep 5
echo $comm10
sleep 5
echo exit
echo exit
sleep 5 ) | ssh $router >> ~/s/files/Router.commands
done
mailx -s "Router Output Requested"
mymail@mail.com < ~/s/files/Router.commands
rm ~/s/files/Router.commands
# END
~~~~~~~~~~~~~~~~~~~
Output:
router metis
sh ver
sh hard
sh env
router metis
sh ver
sh hard
sh env
router metis
sh ver
sh hard
sh env
Thank you
Tony