Find the answer to your Linux question:
Results 1 to 5 of 5
Hello, I'm running mdk 9.0, Bash version 2.05b.0. I'm going through the "Linux Shell Scripting Tutorial v1.05r3 A Beginners Handbook" I would like to be able to execute the scripts ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie
    Join Date
    Aug 2003
    Posts
    113

    Shell script noobie question?


    Hello,

    I'm running mdk 9.0, Bash version 2.05b.0.

    I'm going through the "Linux Shell Scripting Tutorial v1.05r3 A Beginners Handbook"

    I would like to be able to execute the scripts that I make from any directory that I happen to be in.

    To have the ability to do this I have followed the directions in the tutorial yet I'm still unable to execute the script by script name from any directory.

    I've create one script so far by following this tutorial.

    Script name: "first"
    vi first:
    #
    #My first Shell Script
    #
    clear
    echo "Knowledge is Power"

    I then save this and do "chmod +x first"
    sh first...executes fine
    bash first...executes fine
    ./first.....executes fine


    Then I type:
    cd (to make sure I'm in my home directory)
    mkdir bin
    cp first ~/bin

    Then type.... first ..... and I get:
    bash: first: command not found

    If I do "echo $PATH" I get the following:
    /usr/X11R6/bin:/usr/local/bin:/bin:/usr/bin

    This is the default path that was installed by linux ManDrake.

    The Tutorial just assumes that this should work, but it doesn't, and it doesn't offer any other tips as to why it doesn't or what I need to do to get this working.

    Any helps is appreciated.

    Thanks,
    JB

  2. #2
    Linux Newbie
    Join Date
    Aug 2003
    Posts
    113
    Ok...

    What they forgot to mention was that I needed to log out of X and the back in for the changes to take effect. I fogot about this myself.

    So executing "first" from the command line in any directory works now.

    But now this brings on another very curious question.

    And I hope that I can get an answer on this. I've asked before but never really got an explantion for it.

    Question:
    After creating the "bin" directory in my home directory and then logging out and back in my $PATH has changed a bit dramactically. Why is this specifically happening?

    Path statement after making "bin" directory and before logging out =

    /usr/X11R6/bin:/usr/local/bin:/bin:/usr/bin

    Path statement after creating "bin" directory and logging out and the back in =

    /bin:/usr/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/local/bin:/usr/bin:/usr/games:/home/jbanks/bin:/home/jbanks/bin


    Why is /usr/bin and /home/jbanks/bin listed twice in my $PATH statement? My path statement was modified for me transparently. I thought the only way for me to alter my path statement was to edit some cofig files of which I didn't touch.

    Whats causing this to happen?


    Thanks bunches..
    JB

  3. #3
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    It's probably some automagic detection function that Mdk has cooked up. It can be located in several places. I don't have Mdk, so I can't check, but check these files:
    /etc/profile
    /etc/profile.d
    /etc/bashrc
    /etc/X11/xdm/Xsession
    ~/.bash_profile
    ~/.bashrc

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    Sep 2003
    Location
    Quebec, Canada
    Posts
    2
    If ir remember correctly, the $PATH is set in /etc/profile for Mandrake (which I'm pretty sure Mdk stands for, correct me if I'm wrong).

  6. #5
    Linux Newbie
    Join Date
    Aug 2003
    Posts
    113
    Well,
    Thanks for the responses. I've switched from Mandrake (and yes MDK is the short abbrevation for MandDrake...as is if you look at the kernel build with "uname -a" or any rpm's built specifically for Mandrake...)


    I've since switched distro's though. I'm now using Gentoo as my new Linux Distro..love it..and blows Mandrake out of the water along with all the other RPM based distro's.

    JB

Posting Permissions

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