Find the answer to your Linux question:
Results 1 to 9 of 9
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Talking Creating a shell script


    Hello everyone,

    I'm a linux beginer and just got GNURoot Debian in my tablet. There are two commands necessary to make it run which is

    export DISPLAY=:0 PULSE_SERVER=tcp:127.0.0.1:4712

    startlxde &

    Then the guide recommends putting them in a shell script to easily restart lxde and that's where I'm lost. Found some guides on how to create such type of file but none seem to have baby steps and none of my attempts have worked.

    Help?

    Thank you!

  2. #2
    Super Moderator Roxoff's Avatar
    Join Date
    Aug 2005
    Location
    Nottingham, England
    Posts
    4,087
    BASH scripts is a pretty big subject, but a good grounding can be found here:

    https://www.howtoforge.com/tutorial/...pting-lessons/

    I'm not sure if it'll lead you where you need to go, but it's a point of start. That tutorial has links out to other beginners help that might get you going. If there's stuff there you don't understand, feel free to ask here for help.
    Linux user #126863 - see http://linuxcounter.net/

  3. #3
    Linux Guru Segfault's Avatar
    Join Date
    Jun 2008
    Location
    Acadiana
    Posts
    2,185
    startlxde is executed from command line. This means user has been logged in already. This, it turn, means shell is running, probably bash. If it is bash, you can put all that and startlxde into ~/.bash_profile or ~/.bashrc and your LXDE will start automatically when user logs in.

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Guru
    Join Date
    Dec 2013
    Posts
    2,747
    ^ it would have to be ~/.bash_profile, not ~/.bashrc, since that gets executed everytime you open a new shell (e.g. open a terminal).

    manchurian, ~/.bash_profile is a file in your home directory.
    it is hidden; you can unhide it by pressing Ctrl-H in your filemanager.
    can you see it? can you add the lines from your first post to it?
    can you log out/in, and will that automagically start LXDE?

  6. #5
    Linux Guru Segfault's Avatar
    Join Date
    Jun 2008
    Location
    Acadiana
    Posts
    2,185
    All ~/.bash_profile files I've seen source ~/.bashrc, so there is no difference. Does not mean I have seen everything.

  7. #6
    Linux Guru
    Join Date
    Dec 2013
    Posts
    2,747
    Quote Originally Posted by Segfault View Post
    All ~/.bash_profile files I've seen source ~/.bashrc, so there is no difference. Does not mean I have seen everything.
    yes, but not the other way round.
    .bashrc does not source .bash_profile.
    so there is a difference.
    because opening a gui terminal sources .bashrc, and not .bash_profile (although i have seen the insanity of gnome-terminal that started every terminal as a login shell, but i think even they have learned to not do that).

  8. #7
    Quote Originally Posted by nihili View Post
    yes, but not the other way round.
    .bashrc does not source .bash_profile.
    so there is a difference.
    because opening a gui terminal sources .bashrc, and not .bash_profile (although i have seen the insanity of gnome-terminal that started every terminal as a login shell, but i think even they have learned to not do that).
    Anyway, that same day I was able to make a working scrip. Next, the script is debian.sh, thus gotta type ./debian.sh for it to run. I was reading about shortcuts but again, didn't work out, I'm looking at only needing to type debian to trigger the script.

  9. #8
    Linux Guru
    Join Date
    Dec 2013
    Posts
    2,747
    Quote Originally Posted by manchurian View Post
    I'm looking at only needing to type debian to trigger the script.
    stick the script in $HOME/bin and make sure $HOME/bin is in your $PATH.

  10. #9
    Linux User
    Join Date
    Apr 2015
    Location
    Yorkshire, England
    Posts
    261
    -->
    Once you've moved it to $HOME/bin rename it with
    Code:
    mv ~/bin/debian.sh ~/bin/debian
    alternatively create a link to it
    Code:
    cd ~/bin
    ln -s debian.sh debian
    . Just because it's a shell script it doesn't have to have a .sh ending, this is not microsoft where .com , .exe and .bat have meaning

Posting Permissions

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