I have a bash script that takes a file 开发者_如何学运维name as an arg. It works great from the command line. When I right-click a file in KDE and select "open with", then point it to my script, it doesn't run. What am I doing wrong?
It is possible that your script relies on environment variables that get set by the terminal log in session. I don't know about KDE, but in Gnome, you can check "Open with Terminal" to ensure that the program is launched from a new Terminal session (with the same environment you'd get from ~/.bashrc). My suggestion is to add the following to the start of your script to ensure that it is being invoked:
echo "I've been called: $@" > i_was_invoked.txt
And then, elsewhere in your script, you should put printf/echo statements to determine where it has gone awry. If you do that and post your script, it may be possible to assist you further.
精彩评论