0

I wrote a script named vpn.sh.The contents is as follows:

#!/bin/sh

cd /etc/openvpn

sudo openvpn client.ovpn &

when I am in konsole, ./vpn.sh runs well. But when I double click the vpn.sh file, it has no response. Can someone tell me the difference between the above two methods?

2
  • 1
    This belongs on Super User, it is not a programming question.
    – Charles Goodwin
    Commented Jul 21, 2011 at 4:26
  • Or Unix and Linux Commented Jul 21, 2011 at 4:28

3 Answers 3

1

I would say that using sudo works in command-line (as it allows one to type a password on the command-line), but will probably not work in a graphical environment.

In such a situation, you should use gksudo or kdesudo, depending on the desktop environment you're using -- see Graphical sudo for more informations.

1

It sounds like whatever you are using as a file browser is not set up to execute .sh files as shell scripts. When you are in a terminal and you type ./vpn.sh it executes the file as a shell script in the terminal. When you attempt to perform the same action by double clicking on the file your file browser is not set up to handle the script in the same way and will do nothing.

0

are you running it as an administrator/root when you double click it?

when you run it from console you used sudo and that signifies you are running the file as admin/root

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .