I am sure it is a silly question but here is what I am doing:
# pwd
/root/bin
# echo "cd /" > foo
# sh foo
# pwd
/root/bin
How can I make foo script file to change the directory to "/"
Thanks,
Rami
This is a discussion on "cd" doesn't take effect when running in script, but does in console within the Linux Programming forums, part of the Platform Specific Boards category; I am sure it is a silly question but here is what I am doing: # pwd /root/bin # echo ...
I am sure it is a silly question but here is what I am doing:
# pwd
/root/bin
# echo "cd /" > foo
# sh foo
# pwd
/root/bin
How can I make foo script file to change the directory to "/"
Thanks,
Rami
I hope your browser isn't running as root as well.
You need to 'source' the script if you want it to take effect in the current environment.
So rather than
# sh foo
You would do
# source foo
or
# . foo
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I support http://www.ukip.org/ as the first necessary step to a free Europe.
thx salem. it worked
I am the root.
what do you mean "I hope your browser isn't running as root as well."
--Rami
As in, you lazily did
# firefox &
Now, your browser is running as root, which means anything which manages to compromise your browser will also be running as root. At that point, it's "bye bye" machine, and you're looking for your install disks.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I support http://www.ukip.org/ as the first necessary step to a free Europe.