2011-06-21 65 views
1

當以圖形方式啓動時(通過雙擊腳本圖標並選擇運行),此腳本無法正常運行,但如果從終端調用則運行得很好;不會保存文件或從現有文件加載內容。請幫忙!謝謝。當在終端外運行時,Bash腳本不工作

#!/bin/bash 

# This script provides a simple and secure messaging system for users not 
# familiar with gpg or using the terminal. The idea is to keep sensitive 
# plaintext files off one's computer. 

zenity --question --text="Select operation:" --ok-label="Compose" --cancel-label="Read" 
if [[ $? == 0 ]]; then 
    usr=$(zenity --entry --text="Sender Key ID:") 
    rec=$(zenity --entry --text="Recipient Key ID:") 
    pwd=$(zenity --password) 
    outfile=$(zenity --file-selection --save --confirm-overwrite) 
    zenity --text-info --editable | gpg -aseu $usr -r $rec --passphrase $pwd --cipher-algo AES256 -o $outfile 
else 
    infile=$(zenity --file-selection) 
    pwd=$(zenity --password) 
    gpg -d --passphrase $pwd $infile | zenity --text-info --height=600 --width=800 
fi 
+2

來吧,你現在應該知道「不能正常工作」並不是一種診斷... –

+1

對不起,我週二沒有讀過頭腦。你必須實際告訴我們什麼不起作用。 – cledoux

+0

對不起。如果腳本通過雙擊運行,然後選擇運行,它將執行,但不會保存文件或從現有文件加載內容。 – Sharon

回答

1

可能的原因的錯誤是你通過一個交互式shell執行時(因此採購的.bashrc)和雙擊(非交互,而不是採購有不同的環境.bashrc

你可以通過做env > from_terminalenv > double_click,然後使用diff或類似的東西比較的環境。

你也可以源from_terminal在你的腳本,看它是否與終端環境下工作(以上後做)。作爲國家d在其中一條評論中,set -vx是你的朋友。

相關問題