Using variables across script

Hi,
I want to take input from one script like :

  1. Enter ip address :
  2. Enter port :

Now, I want to -
a. Store these in variables,
b. Call a separate script (say, x) from this script (say, y)
c. And use the stored variables in the called script (i.e. in script 'x').

How do I go about these steps ?

Here you can find how to assign the input to a variable:

Internal Commands and Builtins

After reading the variables you can call script x as:

./x var1 var2

In script x the variables are available as $1 and $2.

Have a read of some tutorials/books regarding shell scripting:

http://www.unix.com/answers-frequently-asked-questions/13774-unix-tutorials-programming-tutorials-shell-scripting-tutorials.html

Hi,
I declared some variables & assigned values in a script X like :-

ipAddr="192.168.1.1"
port=6596

now, at the end of script X I am calling script Y as -

./Y ipAddr port

Also, I tried

./Y $ipAddr $port

It always says unexpected end of file :confused:

Not seeing all the scripts, my crystal ball says that you have a problem in either X or Y scripts (most likely it's "unexpected end of file").

Hi,
If I remove the last line i.e. where I am calling the other script, then things are ok. :b:
Also, both the scripts x and Y, indivisually runs fine. i.e. if I type ./X or ./Y on the command line, there is no issue. :frowning:

Once again.... my crystal ball is getting even more fuzzier with every post.
Without seeing the script I don't think you can be helped.
Good luck!