2017-12-21 3 views
-1

私はダイアログを使用するスクリプトファイル(sh-file)をプログラミングしています。私はエラーを探すのに怒っているので、数週間はそれを面倒にしておきたいと思っています。最初のコマンドはなぜ実行されますが、最後の2つではありません(統計とダイアログ)?

必要スクリプト部分注意:

INPUT=/tmp/input.sh.$$ #Just a tmp file used for storing information 
FIELDS=/tmp/fields.sh.$$ #Just a tmp file used for storing information 

function view_folder_properties() { 
    dialog --title "Choose a folder to view properties from" --dselect/23 60 2> $INPUT 
    location=$(<"${INPUT}") 

    stat $location > $FIELDS 
    dialog --title "Viewing permissions" --textbox $FIELDS 23 60 
} 

問題は、コードの最初の2行ではありませんが、私はSTATと、ダイアログを実行したいとき、それはこのようになりますエラーの2行を返します。

./lab-E.sh: line 232: stat: command not found 
./lab-E.sh: line 233: dialog: command not found 

私はほとんど1〜2時間の問題を探していると、まだ私はあなたの助けを求めています理由です、何の問題を見つけることができません。私のシステム上の$ PATH変数をエコー

は次のようになります。

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/ProgramData/Oracle/Java/javapath_target_98747640:/mnt/c/Program Files (x86)/Razer Chroma SDK/bin:/mnt/c/Program Files/Razer Chroma SDK/bin:/mnt/c/Program Files (x86)/Intel/iCLS Client:/mnt/c/Program Files/Intel/iCLS Client:/mnt/c/Windows/System32:/mnt/c/Windows:/mnt/c/Windows/System32/wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0:/mnt/c/Windows/System32:/mnt/c/Windows:/mnt/c/Windows/System32/wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0:/mnt/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/DAL:/mnt/c/Program Files/Intel/Intel(R) Management Engine Components/DAL:/mnt/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/IPT:/mnt/c/Program Files/Intel/Intel(R) Management Engine Components/IPT:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Program Files (x86)/IVI Foundation/VISA/WinNT/Bin:/mnt/c/Program Files/Intel/WiFi/bin:/mnt/c/Program Files/Common Files/Intel/WirelessCommon:/mnt/c/Windows/System32:/mnt/c/Windows:/mnt/c/Windows/System32/wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0:/mnt/c/Program Files (x86)/GtkSharp/2.12/bin:/mnt/c/Program Files/dotnet:/mnt/c/Users/<USERNAME>/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/<USERNAME>/AppData/Local/GitHubDesktop/bin:/snap/bin 

ダイアログおよびSTATパス/ usr/binが

[email protected]:~# which stat 
/usr/bin/stat 
[email protected]:~# which dialog 
/usr/bin/dialog 
[email protected]:~# 
+0

私の仮定は、これらのバイナリは、販売から実行されたときにあなたの$ PATH上にあるが、あなたのスクリプト環境の$ PATHにはない場所にあるということです。 'which stat'を実行すると、完全修飾パスが表示されます。スクリプトでこれを試してみるか、PATHを調整してください。 –

+0

関数view_folder_propertiesの最後を除いて、スクリプト内のどこにでもコマンドを使用できます。 – Erik

+4

あなたの質問には、スクリーンショットではなくコード形式のテキストとしてコードを含めてください。 –

答えて

1

statdialog上記の$ PATHにあるシェルされていません彼らは外部プログラムです。完全パスがない場合、その場所は通常、共通の場所(それぞれ/bin/usr/bin)を含む$PATH環境変数で検索する必要があります。

しかし、前の行で$ PATHを変更しました。新しい$ PATHには、おそらくコマンドが置かれているディレクトリは含まれていません。

変数にシステムのパスではなくパスを保存したい場合は、別の名前を選択してください($pathはOK)。

+0

関数の終わりを除いて、スクリプト内の他のどこでもコマンドを使用できます。view_folder_properties – Erik

+0

あなたは** after * *あなたは$ PATHの値を変更しますか? – choroba

+0

明らかにPATH変数は私のマシンでは変更できません。これを何度も実行してください。 Windows 10上でサブシステムとしてUbuntuを使用している可能性があります – Erik

関連する問題