You are not logged in.

#1 2009-04-07 05:01:25

m3lkor
Member
Registered: 2009-03-15
Posts: 7

$PATH problems [solved]

ok so can't find anyone else who's done this (and probably isn't anyone else)
but
trying to learn how to write scripts n such, wanted to add the script folder to $PATH.

export PATH="$PATH:~/scripts
> "

that was it, type echo $PATH to see if it worked,
it didn't, said it could not find file or directory
realized i had screwed up with the " at the end, tried to add it again (correctly and with full path), no change in $PATH at all. still had the error.
upon looking online thought i saw that if you only export it does not save anything to $PATH permanently so, added what i thought was the correct line to my .bashrc
export PATH="$PATH:/home/user/scripts"
and rebooted......

entered username and password into slim, failed , tried again failed, went to first console
tried to ls , can not find command
tried vi /home/usr/.bashrc no go, vim /home/usr/.bashrc no go, can't find the command

edit: - I had also checked what PATH was, only had the directory from my .bashrc -

so started adding directory's
export PATH="/bin:/sbin:/usr/bin:/usr/sbin:/etc:/var/run"

managed to log in, and now things appear ok, but...
how do i correctly add an item to my PATH, how do i restore (if possible) my old path

reading path now, only has the items i put in, when i path'd before had 3 lines not including the error

the path var has been removed from .bashrc

thank you for any pointers.

Last edited by m3lkor (2009-04-07 05:36:24)

Offline

#2 2009-04-07 05:19:42

Mektub
Member
From: Lisbon /Portugal
Registered: 2008-01-02
Posts: 647

Re: $PATH problems [solved]

For example, in my ~/.bash_profile I have a line that reads:

export PATH=$PATH:$HOME/bin:/usr/local/bin

This works. Just check that the following lines in ~/.bash_profile or ~/.bashrc do not reset PATH.

Mektub


Follow me on twitter: https://twitter.com/johnbina

Offline

#3 2009-04-07 05:36:02

m3lkor
Member
Registered: 2009-03-15
Posts: 7

Re: $PATH problems [solved]

that was it, thanks for the help.
could the " " i was putting in have screwed it up?

Offline

#4 2009-04-07 11:58:11

Mektub
Member
From: Lisbon /Portugal
Registered: 2008-01-02
Posts: 647

Re: $PATH problems [solved]

m3lkor wrote:

that was it, thanks for the help.
could the " " i was putting in have screwed it up?

No,

export PATH="$PATH:$HOME/bin:/usr/local/bin"

should be the same.

The "" takes off the expansion of special characters like '*', but not the expansion of '$' variables.

Single quotes "'" does take off the expansion of '$' variables.

Test with:

echo $PATH
echo "$PATH"
echo '$PATH'

Mektub


Follow me on twitter: https://twitter.com/johnbina

Offline

Board footer

Powered by FluxBB