2011-06-21 68 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是你的朋友。

相关问题