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?

migrated from stackoverflow.com Jul 21 '11 at 18:43

This question came from our site for professional and enthusiast programmers.

  • 1
    This belongs on Super User, it is not a programming question. – Charles Goodwin Jul 21 '11 at 4:26
  • Or Unix and Linux – Chris Knadler Jul 21 '11 at 4:28
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.