LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 12-16-2004, 11:57 PM   #1
pito
LQ Newbie
 
Registered: Dec 2004
Location: Sweden
Distribution: Fedora
Posts: 5

Rep: Reputation: 0
How to run SHELL script


Hi

I use Linux Fedora Core 3 on a Laptop

I want to run a shell script "test.sh" , but it does not work.

1. I try to run from Terminal window entring in command line
$test<enter>

Bash answer - unknown command

2. I try to run
$test.sh<enter>

Bash answer - unknown command

The script looks like:
#!/bin/sh
echo "My test script"
ls - l

So I changed to super user and tried the same with the same result

Then I run a set command and seen that the variable SHELL=/bin/bash

My next try was to change the first line into

#!/bin/bash

but it does not helped at all.

Since I am rather new in linux world I would like to get some help to what is that I am doing wrong

/PiTo
 
Old 12-17-2004, 12:03 AM   #2
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
Hi.

To run a script or program in the current directory, do ./test.sh

Dave
 
Old 12-17-2004, 01:43 AM   #3
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
Also make sure the file has executable permission. You can do that with:
chmod u+x test.sh
 
Old 12-17-2004, 02:36 AM   #4
pito
LQ Newbie
 
Registered: Dec 2004
Location: Sweden
Distribution: Fedora
Posts: 5

Original Poster
Rep: Reputation: 0
Thanks for the info...

Yes it looks like Dave gave mi answer I needed.

I needed ./ in order to specify curren directory.

Thanks again, now I cen continue to play around.

/pito
 
Old 12-17-2004, 03:05 AM   #5
yano
Member
 
Registered: Nov 2004
Location: Slovak republic - Bratislava
Distribution: debian & gentoo
Posts: 43

Rep: Reputation: 15
Hmm, You should study something about Your PATH variable.
This is quite different from other OS, becouse You can not run program directly when You do not specify You want to run it in current directory.
It is becouse of security reasons. Imagine, if some "hacker" puts a shellscript named "ls" into /tmp, something like this:

#!/bin/sh
echo "Haha I got u!";
rm -rvf /

You as "root" came to /tmp and type "ls". ;-) Not very good idea. Bud, we are in linux, so You can modify your PATH variable, can add ./ there If You know what You are doing.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run Shell Script on logon thesystem Debian 2 10-20-2005 11:11 AM
run shell script on cron varunbihani Linux - Newbie 5 07-08-2005 01:50 AM
Shell script to run pl/sql script. colly Linux - General 1 09-09-2004 06:49 AM
how do i run shell script? krt47 Linux - Newbie 4 08-02-2004 09:29 AM
how to run a shell script oasisbhrnw99 Linux - Newbie 1 05-05-2004 01:21 PM


All times are GMT -5. The time now is 11:20 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration