The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 07:13 AM
passing two variables into a shell script? Bashar Shell Programming and Scripting 2 05-15-2007 11:00 AM
passing variables to sed inside script Daniel234 Shell Programming and Scripting 5 11-24-2005 06:15 AM
passing variables to awk from ksh script rein Shell Programming and Scripting 3 08-11-2005 12:29 PM
Passing filenames/variables into a script MrToast Shell Programming and Scripting 5 03-02-2004 10:15 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-18-2002
tcoventr tcoventr is offline
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
  #2 (permalink)  
Old 06-18-2002
epdgesell epdgesell is offline
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 (permalink)  
Old 06-18-2002
tcoventr tcoventr is offline
Registered User
  
 

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

Thank you for your prompt answer!!!
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:36 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0