2016-04-26 18 views
0

bashスクリプト(またはどの言語でも)がヘッドレスで実行されているかどうかを判断する方法はありますか?ユーザーが入力できるかどうかを知りたい彼らができるなら、私は彼らに何かを尋ねるつもりです。スクリプトは、ユーザーが入力できるかどうかをどのように知ることができますか?

+0

あなたは '-t'フラグに' [ '/' test'との接続のttyを確認することができます。 –

+0

これはどのように広すぎますか? –

+0

「bashスクリプト(または何でも)」はかなり広いです。また、「ヘッドレスウェイ」は、それ以上の明確化なしではかなり広いです。それは私が(bashのための)答えがかなり単純明快だと言った。 –

答えて

0

男のbashのから:

An interactive shell is one started without non-option arguments and without the -c option whose standard input and 
     error are both connected to terminals (as determined by isatty(3)), or one started with the -i option. PS1 is set and 
     $- includes i if bash is interactive, allowing a shell script or a startup file to test this state. 
関連する問題