I have 8 folders namely HCIVR5,HCIVR6,HCIVR7,HCIVR8,IVR5,IVR6,IVR7,IVR8. I wrote down this code first
ls -d IVR* > temporary.txt
Saved this code in a file called run. then executed it using ./run. When i tried opening the file(using cat and normal opening through click), it said "cannot access temporary.txt.
This is my entire code
ls -d IVR* > temporary.txt
while read ivr_line;do echo $ivr_line;cd $ivr_line;./ivr_alarm;cd ..;done < temporary.txt
ls -d HCIVR* > temporary.txt
while read hcivr_line;do echo $hcivr_line;cd $hcivr_line;./hcivr_alarm;cd ..;done < temporary.txt
Now this program works for IVR5,6,7,8. After that i get the error ./run: line 4: temporary.txt: No such file or directory even when i comment the first two lines i get the same error
code for ivr_alarm is this
mkdir TEMP
day=`date +%d-%m-%Y`
read ip<ip.txt
read ivr_number<ivr_number.txt
while read line;do scp -i ivr"$ivr_number"_key -r root@$ip:${line%?} ./TEMP/ ;done < files_needed.txt
mv ./TEMP/.bash_history ./LOGS/.bash_history_"$day"
cd TEMP
for file in *;do
mv $file ../LOGS/${file%.*}_"$day".${file##*.}
done
cd ..
rmdir TEMP
code for hcivr_alarm is this
day=`date +%m-%d-%Y`
read ip<ip.txt
read ivr_number<ivr_number.txt
rm alarmtest
rm ./LOGS/HEALTH_CHECK_$day.log
while read line;do
echo "ssh -i hcivr"$ivr_number"_key root@$ip '${line%?}'>>./LOGS/HEALTH_CHECK_$day.log" >> alarmtest
done < commands.txt
chmod 700 alarmtest
./alarmtest
and for alarmtest(for HCIVR5, key changes to hcivr6_key for HCIVR6 and so on) is this
ssh -i hcivr5_key root@172.19.66.137 'ocstatus'>>./LOGS/HEALTH_CHECK_04-25-2012.log
ssh -i hcivr5_key root@172.19.66.137 'ocmp-bre status'>>./LOGS/HEALTH_CHECK_04-25-2012.log
Now this program works for IVR5,6,7,8. After that i get the error ./run: line 4: temporary.txt: No such file or directory even when i comment the first two lines i get the same error. Where am i going wrong . Because when i manually open all the HCIVR folders and run ./hcivr_alarm everything works fine