SSHでいくつかのテストをしたいとしましょう。
はい
ssh 18.23.24.2 2>/dev/null "smartctl -a /dev/sdb -q silent"
echo $?
1
この場合、終了コード 1 が表示されます。
問題がsshまたはsmartctlコマンドに関連しているかどうかを確認する方法は?
ベストアンサー1
マンページから:
EXIT STATUS
ssh exits with the exit status of the remote command or with 255 if an error occurred.
sshコマンドでエラーが発生した場合は255を返し、そうでない場合はリモートコマンドの終了ステータスを返します。
例:
$ ssh [email protected]
ssh: Could not resolve hostname not.exists: Name or service not known
$ echo $?
255
smartctl
あなたの場合、1はコマンドの終了状態ではありませんssh
編集する:
smartctl終了ステータス:
EXIT STATUS
The exit statuses of smartctl are defined by a bitmask. If all is well with the disk, the exit status (return value) of smartctl is 0 (all bits turned off). If a problem occurs, or an error,
potential error, or fault is detected, then a non-zero status is returned. In this case, the eight different bits in the exit status have the following meanings for ATA disks; some of these values
may also be returned for SCSI disks.
Bit 0: Command line did not parse.
Bit 1: Device open failed, device did not return an IDENTIFY DEVICE structure, or device is in a low-power mode (see '-n' option above).
Bit 2: Some SMART or other ATA command to the disk failed, or there was a checksum error in a SMART data structure (see '-b' option above).
Bit 3: SMART status check returned "DISK FAILING".
Bit 4: We found prefail Attributes <= threshold.
Bit 5: SMART status check returned "DISK OK" but we found that some (usage or prefail) Attributes have been <= threshold at some time in the past.
Bit 6: The device error log contains records of errors.
Bit 7: The device self-test log contains records of errors. [ATA only] Failed self-tests outdated by a newer successful extended self-test are ignored.
smartctlの終了ステータス1は1 = 2^0なので、ビット0がオンになっているため、コマンドラインを解析できないことを意味します。