LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices



Reply
 
Search this Thread
Old 09-19-2005, 09:09 PM   #1
Red Squirrel
Member
 
Registered: Dec 2003
Distribution: FC9 on main server
Posts: 822

Rep: Reputation: 36
Passing variables to an include?


I have a script that includes another script, like this:

$include /data/scripts/path_lists/${backup_name}>${backup_dest}/${backup_name}__d.log

But the variables arn't being past to the script (there's others as well as the ones you see). Is there a way to make the variables work in the script being included?
 
Old 09-19-2005, 10:42 PM   #2
Matir
Moderator
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 118Reputation: 118
In what language are you doing this? As far as I'm aware, include is not a bash construct. 'source' is the standard method in bash.
 
Old 09-19-2005, 10:43 PM   #3
Red Squirrel
Member
 
Registered: Dec 2003
Distribution: FC9 on main server
Posts: 822

Original Poster
Rep: Reputation: 36
Yeah it's bash. The include is working, since the script is running, but it's just not reconizing any variables that are declared in the parant script.
 
Old 09-19-2005, 10:55 PM   #4
Matir
Moderator
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 118Reputation: 118
Is include a script of your own?

I have used:
Code:
script1.sh:
#!/bin/bash
echo ${WORD}

script2.sh:
#!/bin/bash
export WORD="hello"
source script1.sh
export WORD="world"
source script1.sh

$ ./script2.sh
hello
world
 
Old 09-23-2005, 10:18 PM   #5
Red Squirrel
Member
 
Registered: Dec 2003
Distribution: FC9 on main server
Posts: 822

Original Poster
Rep: Reputation: 36
So export will bring the value from the specified script to itself? That should work, and yes it's a script of my own so I can edit it no problem.
 
  


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
PHP passing variables from url to ... latino Programming 3 08-31-2005 07:35 PM
Passing SSI variables between pages dubya Programming 2 07-05-2005 03:06 PM
passing variables to sed jjfate Programming 8 07-31-2003 05:15 AM
Passing variables to preg_match patterns? RecoilUK Programming 0 06-23-2003 11:57 PM
Passing variables in PHP???? vous Programming 3 03-20-2003 07:03 AM


All times are GMT -5. The time now is 01:12 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration