LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 11-26-2004, 09:01 PM   #1
zz_s
LQ Newbie
 
Registered: Sep 2004
Posts: 5

Rep: Reputation: 0
Question csh script variables setting


Hi All,

I wrote a csh (C-shell) script name "myscript" that only does setting of variables and nothing else.

--------------------------------------------------
#!/usr/bin/csh -f

set group = "mike mary jack jane"
echo $speak

-------------------------------------------------
After changing mode (% chmod 744 myscript) and included the path of the script "/home/me/bin" to my PATH enviroment variables. I did a rehash (% rehash) and assured that my "/home/me/bin" is in the command path. I ran the script "% myscript" and returned with "hello world". This is OK.

% myscript
mike mary jack jane

The problem is it doesn't set the variable "speak" in my current shell.

% echo $speak
speak : Undefined variables.

It seems that the variable "group" has been set during the script but somewhat out of scope after leaving the script. Tried finding script books on variable setting but nothing on scopes. Or have i left out a command after setting? Appreciate if someone can help.....
 
Old 11-27-2004, 03:45 AM   #2
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Code:
% source myscript
will do it (similar to the '.' dot command in bourne shells)
 
Old 12-04-2004, 06:55 AM   #3
zz_s
LQ Newbie
 
Registered: Sep 2004
Posts: 5

Original Poster
Rep: Reputation: 0
Thanks for the big help. Sometimes i just don't know the difference between running an executable file and sourcing it. :-)
 
  


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
Script for csh or bash unihiekka Programming 5 10-15-2005 09:51 AM
Setting environment variables from shell script theta Linux - General 5 09-02-2004 08:50 PM
how do you set an env variable from within a csh script? BrianK Linux - General 3 05-26-2004 02:16 PM
Setting environment variables from a script... sylvain_gnu Linux - Newbie 5 04-20-2004 12:31 PM
running a csh-script from desktop with 1-click ? jdaniel Linux - General 3 10-06-2003 09:35 AM

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

All times are GMT -5. The time now is 07:56 PM.

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