を尋ねる私は、suユーザーになることなく、スクリプトを実行しようと、私はこのために、このコマンドを使用します。パスワードを「エコー 『』 | sudoを-S <command>」パスワード
echo "password" | sudo -S <command>
私はscpコマンド「のために、このコマンドを使用する場合"、" mv "、" whoami "コマンドの場合、コマンドはうまく動作しますが、" chmod "を使用すると、ユーザーにパスワードを要求します。私はパスワードを入力しないでくださいコマンドが動作します。私の問題は、システムが私にパスワードを要求することです。私はシステムがパスワードを尋ねることを望まない。
問題ssは、このようなものです:
[[email protected] test-dir]$ ls -lt
total 24
--wx-wx-wx 1 root root 1397 May 26 12:12 file1
--wx-wx-wx 1 root root 867 May 26 12:12 script1
--wx-wx-wx 1 root root 8293 May 26 12:12 file2
--wx-wx-wx 1 root root 2521 May 26 12:12 file3
[[email protected] test-dir]$ echo "myPassw0rd" | sudo -S chmod 111 /tmp/test-dir/*
[sudo] password for myLocalUser: I DONT WANT ASK FOR PASSWORD
[[email protected] test-dir]$ ls -lt
total 24
---x--x--x 1 root root 1397 May 26 12:12 file1
---x--x--x 1 root root 867 May 26 12:12 script1
---x--x--x 1 root root 8293 May 26 12:12 file2
---x--x--x 1 root root 2521 May 26 12:12 file3
これを再現する方法はわかりません。 'sudo -S'は入力を要求するプログラムで少しうまく動作します。標準入力はパスワードの元のパイプに接続されるためです。しかし、「chmod」はAFAIKの入力を期待すべきではありません。最初に 'sudo -s'でシェルを開き、' chmod 111 ... 'を実行すると、問題のあるコマンドは何をしますか?仕事をする他のプログラムと比較していくつかの違いがありますか? – ilkkachu