LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-05-2005, 05:03 AM   #1
Suinatsa
Member
 
Registered: Jul 2004
Distribution: Slackware, Suse
Posts: 46

Rep: Reputation: 15
Question cd in shell script


Hey guys

I am having trouble with a shell script again.

I want to write a little shell script (bash) to execute two cgi-scripts which are stored in two different directories.

The problem is that it is not enough when I specify the path where the scripts are and then execute them. Whenever I want to start them from the commandline I have to do the following steps:

cd /somewhere/great/
/somehwhere/great/cgi-script

So I have to change into the directory and whenever I want to start the script I have to type in the location again with the script name.

So how do I do this in a script? I have to force the script to change into the directory and THEN execute the script with the full path name again.

THX

Suinatsa
 
Old 05-05-2005, 05:18 AM   #2
davholla
Member
 
Registered: Jun 2003
Location: London
Distribution: Linux Mint 13 Maya
Posts: 729

Rep: Reputation: 32
It could be and I rusty at this so I could be wrong. That the directory where they are is not executable, try ls -lad in the directory. This will tell you the permissions.
Also why don't you add this directory to your path ? Then you will be able to run the script without putting the path.
 
Old 05-06-2005, 06:31 AM   #3
Suinatsa
Member
 
Registered: Jul 2004
Distribution: Slackware, Suse
Posts: 46

Original Poster
Rep: Reputation: 15
Hey,


thanks for the reply. System aka root is running this script and the permissions are ok.
I added the directory to PATH with

PATH=/somewhere/great:$PATH
and whenever I do
echo $PATH
it is in the list so that is ok. But still when I run the script it gives me the error that I am not in the directory.

Does the script runs every command from the directory where it is executed from?

THX

Suinatsa
 
Old 05-06-2005, 07:36 AM   #4
davholla
Member
 
Registered: Jun 2003
Location: London
Distribution: Linux Mint 13 Maya
Posts: 729

Rep: Reputation: 32
Could you print your whole script ?
 
Old 05-06-2005, 11:51 AM   #5
rstewart
Member
 
Registered: Feb 2005
Location: Sunnyvale, CA
Distribution: Ubuntu
Posts: 205

Rep: Reputation: 38
Hi,

What happens if you:

cd /tmp
/somehwhere/great/cgi-script

What error messages are displayed?

echo $PATH

What is displayed?
 
  


Reply



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
Shell script inside shell script treotan Linux - General 4 02-19-2009 06:34 AM
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 02:14 AM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 05:32 PM
Directory listing - Calling shell script from a CGI script seran Programming 6 08-11-2005 11:08 PM
[SHELL SCRIPT] Write at the right of the shell window Creak Linux - General 2 04-02-2004 03:00 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:03 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration