The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
passing variables to sed function in a script .... shweta_d Shell Programming and Scripting 2 06-05-2007 03:13 AM
passing two variables into a shell script? Bashar Shell Programming and Scripting 2 05-15-2007 07:00 AM
passing variables to sed inside script Daniel234 Shell Programming and Scripting 5 11-24-2005 03:15 AM
passing variables to awk from ksh script rein Shell Programming and Scripting 3 08-11-2005 08:29 AM
Passing filenames/variables into a script MrToast Shell Programming and Scripting 5 03-02-2004 07:15 AM

Closed Thread
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 06-18-2002
Registered User
 

Join Date: Jun 2002
Location: UK
Posts: 3
Question Passing variables from one script to another

Hi there,

I am trying to write a script (lets call it "script 1") which askes the user for information which is then set as a variable within script 1. Further on within this script, I would like to call another script (script 2) and pass the variables from script 1 to script 2.

Having just read around the board, I have learnt that it is not possible to pass variables directly between scripts, however I understand that it may be possible "dump" the variables from script 1 into a file and then get script 2 to read them.

Question is (if you have not guessed already!!) is how??

Many thanks in advance.

TOM

P.S. This is not homework or school related in any way!!!!! I am simply a novice
Forum Sponsor
  #2  
Old 06-18-2002
Registered User
 

Join Date: Jun 2002
Location: NJ
Posts: 10
There are ways to pass variables to a new script from you existing script. When you start a script you can send variables in the following manner : filename variable variable variable
Unix sees the variable as $1 $2 $3 ....

Your second script would then be able to use the variable by thier number or you can assign them a name within the script.

Example.
Script one:
echo $1
{fullpathname}/scripttwo $2 $3

Script Two:
echo "this is the second script"
echo $1
echo $2

If the user entered scriptone this is fun
the computer would respond
this
this is the second script
is
fun

As you can see you send the second and third variable to scripttwo. Script two sees this as the first and second variable sent to it for processing.

Hope this helps
  #3  
Old 06-18-2002
Registered User
 

Join Date: Jun 2002
Location: UK
Posts: 3
Excellent!!!

Thank you for your prompt answer!!!
Google The UNIX and Linux Forums
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 07:34 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0