Find the answer to your Linux question:
Results 1 to 5 of 5
Hi All, I've set up a bash file that looks like this: #!/bin/bash sudo /etc/init.d/vpnclient_init start sudo ifconfig eth0 down vpnclient connect UCIFull it's to VPN into my work office ...
  1. #1
    Linux Guru jmadero's Avatar
    Join Date
    Jul 2007
    Location
    California
    Posts
    1,958

    Strange Bash Behaviour

    Hi All,

    I've set up a bash file that looks like this:

    #!/bin/bash

    sudo /etc/init.d/vpnclient_init start

    sudo ifconfig eth0 down

    vpnclient connect UCIFull
    it's to VPN into my work office computers. It works great when I directly go to the file. I tried setting up a link to it within my applications so that I didn't have to terminal to it every time:

    gksu bash /home/user/Documents/Computer/Scripts/vpn.sh

    so the strange behaviour is that it almost always does one of two things when I use the link within my applications list:

    1. It starts the script, then it has strange ? marks where it's asking for user name and password, then it just crashes and terminal closes

    2. It asks for username and stops at this point, doesn't close, just hangs.


    So why would calling it from within my menus be different from going to terminal and doing it that way? I have the link set up to run from terminal so it should be identical...shouldn't it?
    Bodhi 1.3 & Bodhi 1.4 using E17
    Dell Studio 17, Intel Graphics card, 4 gigs of RAM, E17

    "The beauty in life can only be found by moving past the materialism which defines human nature and into the higher realm of thought and knowledge"

  2. #2
    Linux User
    Join Date
    Sep 2008
    Location
    UK
    Posts
    353
    You are asking the script to run as su with the lines that begin with sudo, so the system is asking for the root pwd.
    The script has to either be run as root (without the sudo), or perhaps try changing it's ownership to root and allowing users or whatever group you want to run the script to execute it.
    If you don't have to be root to start the vpn client, run it as a normal user (no sudo).

  3. #3
    Linux Guru jmadero's Avatar
    Join Date
    Jul 2007
    Location
    California
    Posts
    1,958
    needs to be root, so basically I can't make a link to it? that would be a bit....disfunctional if I can't
    Bodhi 1.3 & Bodhi 1.4 using E17
    Dell Studio 17, Intel Graphics card, 4 gigs of RAM, E17

    "The beauty in life can only be found by moving past the materialism which defines human nature and into the higher realm of thought and knowledge"

  4. #4
    Linux User
    Join Date
    Sep 2008
    Location
    UK
    Posts
    353
    By typing:' sudo command_string' you are asking that the command be run as root user, so it is always going to pause the output and ask for the root pwd. To get it to run properly, you need to remove the sudo.
    Can you now start and run the vpnclient as a normal user?
    If not, you need to look at the script's ownership and permissions to allow a normal user or a chosen group to be able to run the script.

  5. #5
    Linux Guru jmadero's Avatar
    Join Date
    Jul 2007
    Location
    California
    Posts
    1,958
    the problem isn't that it asks for a password. I have to put in my root password when I run it in terminal manuall as well. This is the order that I do it:

    sudo bash vpn.sh
    root password

    vpn user name
    vpn password

    but when I do it with the icon it does
    click icon
    root password

    vpn user name
    ...hangs

    so the issue isn't that it's asking for a root password
    Bodhi 1.3 & Bodhi 1.4 using E17
    Dell Studio 17, Intel Graphics card, 4 gigs of RAM, E17

    "The beauty in life can only be found by moving past the materialism which defines human nature and into the higher realm of thought and knowledge"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...