Find the answer to your Linux question:
Results 1 to 2 of 2
At the moment, I'm playing with a script. It goes like this: Code: sudo su echo "meow" It's that simple. The script is called "kitty." I have it on the ...
  1. #1
    Linux User Agent-X's Avatar
    Join Date
    May 2005
    Location
    Dimension X
    Posts
    261

    sudo su problem

    At the moment, I'm playing with a script. It goes like this:

    Code:
    sudo su
    echo "meow"

    It's that simple. The script is called "kitty." I have it on the desktop.

    Anyway, when I go into terminal, I do the following.

    Code:
    cd ./Desktop/
    bash kitty
    It goes into root, but it doesn't echo.

    Why does it not echo?

    I eventually want to use scripts like this in a more advanced way. However, at the moment, I'm just trying to access root with a script. Afterwards, I want the script to continue.

    Why does the script not continue after going into root?

  2. #2
    Linux Guru
    Join Date
    Nov 2004
    Posts
    6,110
    This won't work because su is running as a seperate terminal. The echo command will run when you terminate the 'su' with ctrl+d. Why don't you have a shabang in your script?
    Code:
    #!/bin/bash
    The correct way to do it is to write the script you want and then run that script as root or using sudo.

Posting Permissions

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