how do i run scripts in linux?

magomago

Lifer
Sep 28, 2002
10,973
14
76
btw, i just did a clean install over 8.1 and 9 is REALLY nice

anyway, how do i run a .sh file ie:script file in the shell? (I keep thinking Sh-2 and SH-4 damn toshiba :) )
 

TheOmegaCode

Platinum Member
Aug 7, 2001
2,954
1
0
8.1 - 9? Are you talking about Mandrake?

Anyways, try sh filename.sh, or chmod it as executable and try ./filename.sh
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
You have to remember 2 things:

1) The current directory is not in your path, and the shell only runs bare commands from your path. So to run something from the current directory you need to type ./filename
2) Anything you want to run has to have the executable bit set, otherwise it can't be executed.
 

cleverhandle

Diamond Member
Dec 17, 2001
3,566
3
81
Originally posted by: Nothinman

1) The current directory is not in your path, and the shell only runs bare commands from your path. So to run something from the current directory you need to type ./filename

That depends on the distro. Most of them add the current directory to the path for non-root users.

 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
That depends on the distro. Most of them add the current directory to the path for non-root users.

I've never seen one that did that, and I think it's a dumb thing to do too.
 

magomago

Lifer
Sep 28, 2002
10,973
14
76
Mandrake does that. When i open up a shell from the explorer it loads up the same folder too

IE:

if i'm in

/home/ammar/desktop/aureal/drivers

and load up the shell i'll be in the same folder...pretty nice


ok. So do .sh filename.sh
 

cleverhandle

Diamond Member
Dec 17, 2001
3,566
3
81
Originally posted by: magomago
Mandrake does that. When i open up a shell from the explorer it loads up the same folder too

IE:

if i'm in

/home/ammar/desktop/aureal/drivers

and load up the shell i'll be in the same folder...pretty nice

Not sure that's the same thing as what I'm talking about, but it doesn't really matter...

ok. So do .sh filename.sh

Not quite - drop the first period. "sh filename.sh" is correct. The first "." would tell the shell to look for "sh" in the current directory. You don't want to do that - sh is in /bin, and thus already in your path.