Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question

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
add comment

3 Answers 3

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.