ファイルから一連のコマンドを実行するためのスクリプトを作成する
例えば、ファイルには3つのコマンドperl script-a、perl script-b、perl script-c、新しい行の各コマンドがあり、このスクリプトを作成しました
#!/bin/bash
for command in `cat file.txt`
do
echo $command
perl $command
done
問題は、一部のスクリプトが停止したり、終了までに時間がかかり、出力を見たい。 wole bashスクリプトを取り消さないようにtxtファイル内の次のコマンドにジャンプするために実行される現在のコマンドでCTRL + Cを送信する場合にbashスクリプトを作成することは可能です。
ありがとうございました
回答:
回答№1は4あなたは使うことができます trap "continue" SIGINT
無視する Ctrl + c:
#!/bin/bash
# ignore & continue on Ctrl+c (SIGINT)
trap "continue" SIGINT
while read command
do
echo "$command"
perl "$command"
done < file.txt
# Enable Ctrl+c
trap SIGINT
また、電話する必要はありません cat
ファイルの内容を読む。
回答№2の場合は0
#!/bin/bash
for scr in $(cat file.txt)
do
echo $scr
# Only if you have a few lines in your file.txt,
# Then, execute the perl command in the background
# Save the output.
# From your question it seems each of these scripts are independent
perl $scr &> $scr_perl_execution.out &
done
それぞれの出力をチェックして、コマンドが期待どおりに動作しているかどうかを確認できます。そうでない場合は、 kill
各コマンドを終了します。