4
我使用hdiutil裝入sparseimage文件,當我將命令鍵入終端時它工作正常,但當我嘗試將它作爲shell腳本運行時,它會給出錯誤。hdiutil在終端窗口中工作,但不在shell腳本中
下面是代碼:
echo -n 'password' | hdiutil attach -stdinpass file.sparseimage
這是錯誤:
hdiutil: attach failed - Authentication error
我確信密碼正確。誰能告訴我什麼是錯的?
如果shell腳本使用'sh'(這是OS X中'bash'的POSIX兼容版本),'xpg_echo'默認啓用,例如'echo -n password'打印'-n password '用換行符。 – user495470
-n或不應該太重要。問題是-stdinpass似乎不能與echo一起工作。 –