How to pass variables into anothother variables?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to pass variables into anothother variables?
# 1  
How to pass variables into anothother variables?

Below are three variables, which I want to pass into variable RESULT1
username1=userid
poihostname1=dellsys.com
port1=8080
How can I pass these variables into below code...
Code:
RESULT1=$((ssh -n username1@poihostname1 time /usr/sfw/bin/wget  --user=sam --password=123 -O /dev/null -q http://poihostname1:port1 ;) 2>/dev/null || echo "Not Running")

# 2  
Hello manohar2013,

You need to basically use $VAR(just an example) in shell to get the values of variables. Following may help you in same.
Code:
cat var_pass.ksh
username1=userid
poihostname1=dellsys.com
port1=8080
RESULT1=$((ssh -n $username1@$poihostname1 time /usr/sfw/bin/wget  --user=sam --password=123 -O /dev/null -q http://$poihostname1:$port1 ;) 2>/dev/null || echo "Not Running")

Above is just an example, you can use it as per your requirement.


Thanks,
R. Singh
This User Gave Thanks to RavinderSingh13 For This Post:
# 3  
Im getting error:
Code:
$ cat var_pass.ksh
cat: cannot open var_pass.ksh

# 4  
Hello Manohar2013,

I just created script named var_pass.ksh and put commands in it. So you need to create a script if you need named var_pass.ksh or you can simply run the commands itself.
on command line without script.
Code:
 username1=userid
poihostname1=dellsys.com
port1=8080
 RESULT1=$((ssh -n $username1@$poihostname1 time /usr/sfw/bin/wget  --user=sam --password=123 -O /dev/null -q http://$poihostname1:$port1 ;) 2>/dev/null || echo "Not Running")

Thanks,
R. Singh
This User Gave Thanks to RavinderSingh13 For This Post:
# 5  
Problem got solved..Thanks for your suggestion
 

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #243
Difficulty: Easy
The starting point for host-to-host communication on the ARPANET in 1969 was the 1822 protocol.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to pass variables between scripts?

Hello, I have two bash scripts like the following: script 1: #!/bin/bash var=WORLD bash path/to/second/script/script2.bash script 2: #!/bin/bash echo "HELLO $var" I expected the output to be "HELLO WORLD" but instead, I get "HELLO". I understand that when I envoke another bash... (2 Replies)
Discussion started by: jl487
2 Replies

2. Shell Programming and Scripting

how to pass variables to s3cmd in a script file

Hi All, How to pass the variable to s3cmd put command? Iím trying to use this command in a script as below: s3cmd put ${upload_path} s3://${upload_dest} where With the above command in script, the file is not getting uploaded. Please help!!! (4 Replies)
Discussion started by: mjavalkar
4 Replies

3. UNIX for Dummies Questions & Answers

How to pass variables in Expect command?

Hi All, I need to frame a unix script to logon to a unix box. The credentials needs to be obtained from a property file on the same location. I am trying to use 'expect' and 'spawn' command to meet this req. When I am passing values, these commands are working fine. but when I am trying to... (3 Replies)
Discussion started by: mailkarthik
3 Replies

4. Shell Programming and Scripting

Pass variables to a Unix script from a file

Hi, I am running a Java program from a unix script. I need to pass a variable to the Java code from a file. Here are teh details: cat Parm <<this is my Parameter file>> queuename=queue1 and my shell script is : #!/bin/ksh . ./Parm /opt/java1.5/bin/java -classpath ./java.jar... (1 Reply)
Discussion started by: sangharsh
1 Replies

5. Shell Programming and Scripting

pass perl variables to shell script

I have a perl script that opens a text file containing numbers on each line: for example: 755993 755994 755995 755996 755997 755998 The perl script takes these numbers and store them as an array @raw_data, where I can access individual numbers by using $raw_data for the value 755993.... (2 Replies)
Discussion started by: xchen89x
2 Replies

6. Shell Programming and Scripting

pass variables from one script to another

HI all I am calling a script "b" from script "a". In script "a", i connect to database and get month and year. I have to pass these same values to script b. How can i do that. How can i pass parameters from one script to another (3 Replies)
Discussion started by: vasuarjula
3 Replies

7. Shell Programming and Scripting

how to pass variables from Asterisk to a C-script

Hi!I'm trying to write a script in C that Asterisk must call: I would to pass to the script a number digited by the user, make some elaboration with it and then pass the result to Asterisk. I don't understand the mechanism used by Asterisk to pass variable to/from a script: I know that variables... (1 Reply)
Discussion started by: lucio82
1 Replies

8. Shell Programming and Scripting

I can't seem to pass variables properly into a nawk statement

Ok, So up front I'm going to say that I'm a very elementary scripter, and I tend to use tools I don't fully understand, but I shotgun at something until I can get it to work...that said, I can't for the life of me understand why I can't get this to go down the way I want it to. The goal: -to... (6 Replies)
Discussion started by: DeCoTwc
6 Replies

9. Shell Programming and Scripting

How to pass variables to FUNCTION ?

Hi... Actually, I want to pass a few variables to the function and print it. But, its looks like not working. Could some body help me how could i do that ?... below is my program... #!/usr/bin/ksh usage() { echo "Usage: $0 -n -a -s -w -d" exit } rename() { echo "rename $1 $2"... (5 Replies)
Discussion started by: bh_hensem
5 Replies

10. Shell Programming and Scripting

How to pass CSH variables up to the parent?

Hi .. I have a dynamic script called from a programming language called Powerhouse (4GL). The module, called QUIZ, allows the user to call shell commands from within it... i.e. !rm -f mipss156t2cmd1.bat mipss156t2tmp1.txt !printf '#!/bin/csh\n' > mipss156t2cmd1.bat !printf 'setenv... (0 Replies)
Discussion started by: ElCaito
0 Replies