LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
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 07-31-2003, 01:17 AM   #1
Warchief
LQ Newbie
 
Registered: Jul 2003
Posts: 16

Rep: Reputation: 0
a simple shell script


#!/bin/sh
cd /etc/rc.d/init.d

it looks so simple,but doesn't work ,who can tell me why?
 
Old 07-31-2003, 05:01 AM   #2
DIYLinux
Member
 
Registered: Jul 2003
Location: NL
Distribution: My own
Posts: 92

Rep: Reputation: 17
If you would at some extra commands to the script, say the command pwd (print working directory) you would see that the cd command works as expected. But after the script terminates, the calling environment is restored.

If you want to change that in a script, try sourcing it. So use

. scriptname # watch the space after the period

instead of

scriptname
 
  


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
Simple Shell Script Help Kristijan Programming 3 06-13-2005 09:13 PM
Simple shell script mikz Linux - General 1 02-24-2005 07:18 AM
simple shell script sharpie Programming 9 06-02-2004 11:47 PM
Very Simple Shell Script cli_man Linux - Software 5 04-24-2003 10:14 AM
Simple C Shell script is not so simple elconde Programming 2 09-16-2001 11:53 PM


All times are GMT -5. The time now is 06:36 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