というファイルがありますテストファイルディレクトリにあります/ホーム/ユーザー次のコードを使用してください。
#!/bin/bash
echo "Execute command number 1 (bash)"
. /opt/IBM/taddm/dist/bin/control.sh
echo "Execute command number 2 (jython)"
. /opt/IBM/taddm/dist/bin/collect_logs.jy "@g"
コマンド 1 を実行すると、次のメッセージが表示されます。
./test.sh: line 5: /opt/IBM/taddm/dist/bin/control.sh: No such file or directory
ターゲット(/bin)に移動してそこからコマンドを実行しても問題ありません。
コマンド2を実行すると、次のメッセージが表示されます。
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 1: Script: command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 2: $'\E]0': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 2: $'user@XXXXX:~\a\E[?1034h[user@XXXXX': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 3: $'\E]0': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 3: user@XXXXX:/opt/IBM/taddm/dist/log/support[user@XXXXX: No such file or directory
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 4: total: command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 5: -rw-r-----.: command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 5: $'31mTADDM_ISA_Collection.General.20220323140619.zip\E[0m\r': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 6: $'\E]0': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 6: user@XXXXX:/opt/IBM/taddm/dist/log/support[user@XXXXX: No such file or directory
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 7: $'\E]0': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 7: user@XXXXX:/opt/IBM/taddm/dist/log/support[user@XXXXX: No such file or directory
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 8: total: command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 9: $'\E]0': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 9: user@XXXXX:/opt/IBM/taddm/dist/log/support[user@XXXXX: No such file or directory
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 10: $'\E[3': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 10: $'J\E[H\E[2J\E]0': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 10: user@XXXXX:/opt/IBM/taddm/dist/log/support[user@XXXXX: No such file or directory
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 11: $'\E]0': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 11: $'user@XXXXX:~\a[user@XXXXX': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 12: total: command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 13: drwxrwxr-x.: command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 13: $'34m12:35:27\E[0m\r': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 14: drwxrwxr-x.: command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 14: $'34m2022\E[0m\r': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 15: drwxrwxr-x.: command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 15: $'34m22\E[0m\r': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 16: drwxrwxr-x.: command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 16: $'34mCET\E[0m\r': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 17: drwxrwxr-x.: command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 17: $'34mMar\E[0m\r': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 18: -rwxrwxr-x.: command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 18: $'32mmenu.sh\E[0m\r': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 19: drwxrwxr-x.: command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 19: $'34mPM\E[0m\r': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 20: $'\E]0': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 20: $'user@XXXXX:~\a[user@XXXXX': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 21: $'\E[3': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 21: $'J\E[H\E[2J\E]0': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 21: $'user@XXXXX:~\a[user@XXXXX': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 22: $'\E]0': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 22: $'user@XXXXX:~\a[user@XXXXX': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 23: total: command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 24: drwxrwxr-x.: command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 24: $'34m12:35:27\E[0m\r': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 25: drwxrwxr-x.: command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 25: $'34m2022\E[0m\r': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 26: drwxrwxr-x.: command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 26: $'34m22\E[0m\r': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 27: drwxrwxr-x.: command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 27: $'34mCET\E[0m\r': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 28: drwxrwxr-x.: command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 28: $'34mMar\E[0m\r': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 29: -rwxrwxr-x.: command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 29: $'32mmenu.sh\E[0m\r': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 30: drwxrwxr-x.: command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 30: $'34mPM\E[0m\r': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 31: -rw-rw-r--.: command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 32: $'\E]0': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 32: $'user@XXXXX:~\a[user@XXXXX': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 33: $'\E]0': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 33: $'user@XXXXX:~\a[user@XXXXX': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 34: total: command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 35: drwxrwxr-x.: command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 35: $'34m12:35:27\E[0m\r': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 36: drwxrwxr-x.: command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 36: $'34m2022\E[0m\r': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 37: drwxrwxr-x.: command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 37: $'34m22\E[0m\r': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 38: drwxrwxr-x.: command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 38: $'34mCET\E[0m\r': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 39: drwxrwxr-x.: command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 39: $'34mMar\E[0m\r': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 40: -rwxrwxr-x.: command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 40: $'32mmenu.sh\E[0m\r': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 41: drwxrwxr-x.: command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 41: $'34mPM\E[0m\r': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 42: -rwxrwxr-x.: command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 42: $'32mtest.sh\E[0m\r': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 43: $'\E]0': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 43: $'user@XXXXX:~\a[user@XXXXX': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 44: $'\E[3': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 44: $'J\E[H\E[2J\E]0': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 44: $'user@XXXXX:~\a[user@XXXXX': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 46: $'\r': command not found
/opt/IBM/taddm/dist/bin/collect_logs.jy: line 51: syntax error near unexpected token `$'do\r''
'opt/IBM/taddm/dist/bin/collect_logs.jy: line 51: `do
ターゲット(/bin)に移動してそこからコマンドを実行しても問題ありません。
source
また、ファイル拡張子(/bin/controlおよび/bin/collect_logs)なしでコマンドを試して、代わりに試してみましたが、.
やはり役に立ちませんでした。
私のbashスクリプト内で他のスクリプトを実行できないのはなぜですか?
ありがとう
答え1
スクリプトが$ PATHにあり、実行可能な場合は、次のように入力
control.sh
してどこでも実行できることを意味します。collect_logs.jy "@g"
あなたはこれを行うことができます
#!/bin/bash
echo "Execute command number 1 (bash)"
control.sh
echo "Execute command number 2 (jython)"
collect_logs.jy "@g"
ディレクトリを指定する必要がある場合は、点を省略してください。
#!/bin/bash
echo "Execute command number 1 (bash)"
/opt/IBM/taddm/dist/bin/control.sh
echo "Execute command number 2 (jython)"
/opt/IBM/taddm/dist/bin/collect_logs.jy "@g"
まず、実行可能にする必要があります。
chmod +x /opt/IBM/taddm/dist/bin/control.sh
chmod +x /opt/IBM/taddm/dist/bin/collect_logs.jy