English 中文(简体)
bash 书写方式
原标题:Biased behavior of bash script

I have 8 folders namely HCIVR5,HCIVR6,HCIVR7,HCIVR8,IVR5,IVR6,IVR7,IVR8. I wrote down this code first

ls -d IVR* > temporary.txt

在一份叫作的档案中删除了该法典。 之后用./run执行。 在试图打开档案(使用目录和通过点击进行正常开场)时,它说“不能暂时进入。 txt。

这是我整个法典。

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

护堤法是

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 [email protected]  ocstatus >>./LOGS/HEALTH_CHECK_04-25-2012.log
ssh -i hcivr5_key [email protected]  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

问题回答

引证:

ls -d IVR* > temporary.txt
while read ivr_line;do echo $ivr_line;pushd $ivr_line;./ivr_alarm;popd;done < temporary.txt
ls -d HCIVR* > temporary.txt
while read hcivr_line;do echo $hcivr_line;pushd $hcivr_line;./hcivr_alarm;popd;done < temporary.txt

我可以看一看,但我认为,你重写了你目前的名录,有些.。





相关问题
Parse players currently in lobby

I m attempting to write a bash script to parse out the following log file and give me a list of CURRENT players in the room (so ignoring players that left, but including players that may have rejoined)...

encoding of file shell script

How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks

Bash usage of vi or emacs

From a programming standpoint, when you set the bash shell to use vi or emacs via set -o vi or set -o emacs What is actually going on here? I ve been reading a book where it claims the bash shell ...

Dynamically building a command in bash

I am construcing a command in bash dynamically. This works fine: COMMAND="java myclass" ${COMMAND} Now I want to dynamically construct a command that redirectes the output: LOG=">> myfile.log ...

Perform OR on two hash outputs of sha1sum

I want perform sha1sum file1 and sha1sum file2 and perform bitwise OR operation with them using bash. Output should be printable i.e 53a23bc2e24d039 ... (160 bit) How can I do this? I know echo $(( ...

Set screen-title from shellscript

Is it possible to set the Screen Title using a shell script? I thought about something like sending the key commands ctrl+A shift-A Name enter I searched for about an hour on how to emulate ...

热门标签