i want append output of wpa_passphrase file if parameters valid, , leave err msg screen otherwise.
i use
wpa_passphrase 1 111 2>&1 >>file wpa_passphrase 1 111111111 2>&1 >>file but file still contains msg , screen did not:
passphrase must 8..63 characters thanks all
the problem wpa_passphrase writes errors stdout not stderr. code should solve problem:
out=$(wpa_passphrase 1 1111111111) && echo "$out" >> file || echo "$out" the code assigns output variable , echos variable file if preceding command successful, otherwise prints output screen.
Comments
Post a Comment