help passing variable from script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting help passing variable from script
# 1  
Old 03-31-2011
help passing variable from script

Hello,

How can I pass a variable into a 2nd file? I'm running a script:
ls -la $1 >pem99
cat pem99 | awk '{ print $3}' >us99
cat us99 | read us98
This then tells me the owner of a file.
my second file is:
echo OWNER GROUP OTHERS
echo
echo --data-- $us98

but all it's not resolving the variable..

As usual any help much appreciated
# 2  
Old 03-31-2011
Are you talking about the variable $us98..? Then try echo'ing as below..
Code:
echo "--data-- $us98"

# 3  
Old 03-31-2011
Tried that but it's still not working.

my file is:
$ more us99tab
echo " OWNER GROUP OTHERS"
echo " "
echo "--data-- $us98 "

but when I cat it or echo it I get
OWNER GROUP OTHERS
--data--

---------- Post updated at 10:08 AM ---------- Previous update was at 09:40 AM ----------

It's ok I've sussed it out - I need to export the variable before it's defined:

ls -la $1 >pem99
cat pem99 | awk '{ print $3}' >us99
export us98
cat us99 | read us98
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Web Development

Passing variable from PHP to bash script

I am totally new to PHP and I am trying to create a script that will as a user for a hostname and then use the "hostname" variable to generate a report using REST API. I am able to create the html script and php script to GET the "hostname" but I am having trouble passing the hostname variable... (10 Replies)
Discussion started by: kieranfoley
10 Replies

2. Shell Programming and Scripting

Passing variable from file to sql from script

Hi Friend, I have one file in which some number are mentioned and number of lines are vary every time And i need to pass that number to my sql command from script. Suppose i have file acc.txt 45456546456 45464564565 67854353454 67657612132 Number of records are vary every time.... (20 Replies)
Discussion started by: pallvi_mahajan
20 Replies

3. Shell Programming and Scripting

Passing variable from called script to the caller script

Hi all, Warm regards! I am in a difficult situation here. I have been trying to create a shell script which calls another shell script inside. Here is a simplified version of the same. Calling Script. #!/bin/ksh # want to run as a different process... (6 Replies)
Discussion started by: LoneRanger
6 Replies

4. Shell Programming and Scripting

Passing variable as an argument to another script

Hi, I am trying to pass a variable as an argument to another script. While substitution of variable, I am facing a problem. varaiable "a" value should be -b "FPT MAIN". When we pass "a" to another script, we are expecing it to get substitue as ./test.sh -b "FPT MAIN". But, it is getting... (9 Replies)
Discussion started by: Manasa Pradeep
9 Replies

5. Shell Programming and Scripting

Passing variable from shell script to python script

I have a shell script main.sh which inturn call the python script ofdm.py, I want to pass two variables from shell script to python script for its execution. How do i achieve this ????? Eg: main.sh a=3 b=3; c= a+b exec python ofdm.py ofdm.py d=c+a Thanks in Anticipation (4 Replies)
Discussion started by: shashi792
4 Replies

6. Shell Programming and Scripting

passing asterisk to a script as variable

I'm writing a script that will ssh to a number of hosts and run commands. I'm a bit stumped at the moment as some of the commands that I need to run contain wildcards (i.e. *), and so far I have not figured out how to escape the * character so the script doesn't expand it. More specifically, here's... (9 Replies)
Discussion started by: GKnight
9 Replies

7. UNIX for Dummies Questions & Answers

passing variable to my script

Hello everybody: Im trying to run the following script on my sol9 machine: line='' ((lineCount= 0)) export lineCount more /tmp/MSISDNs | wc -l > /tmp/tmp cat /tmp/tmp | read lineCount export lineCount; while (( lineCount > 0 )) do line= tail -$lineCount... (5 Replies)
Discussion started by: aladdin
5 Replies

8. UNIX for Advanced & Expert Users

Passing a variable into an awk script

Hello all, I'm trying to run a script of this format - for i in $(cat <file>); do grep $i <file1>|awk '{print $i, $1, $2}' It's not working - does anyone know how this can be done? Khoom (5 Replies)
Discussion started by: Khoomfire
5 Replies

9. UNIX for Dummies Questions & Answers

passing ip address as a variable to script for ftp

Still a Beginner here .. Does anyone no how to get the IP address of the machine thats logged in (bearing in mind there will be others logged in) while they are logged in to the Unix server and pass this as a variable to a shell script so as I can FTP files to that machine via a shell script, at... (2 Replies)
Discussion started by: Gerry405
2 Replies

10. Shell Programming and Scripting

passing awk variable to the shell script

hi; i have a file containing lines like: 1|1069108123|96393669788|00963215755711|2|0|941||;serv:Pps6aSyria;first:0;bear i want to extract the second, third and fourth record of each line and store it in a file ";" seperated this is what i wrote while read line do ... (3 Replies)
Discussion started by: bcheaib
3 Replies
Login or Register to Ask a Question