passing variable to my script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers passing variable to my script
# 1  
Old 06-18-2007
passing variable to my script

Hello everybody:
Im trying to run the following script on my sol9 machine:

Code:
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 /tmp/MSISDNs | head -1 

        export line

        /opt/msp/opt/SAmsp/bin/prosubm_add -ms $line -hs off -ug postpaid -saa off  -v

        ((lineCount=lineCount-1)) 

done

#

As you can see Im passing all lines one by one to an application called "prosubm_add " which do kind of checking and filtering for value entered by "$line". However, when I test $line or echo it I can get it correct value, and when I substiute it by an integer value It works, but only when pass it as variable it gives me the follwing error:
Code:
Parameter value for parameter with name ( -ms ) is missing.

Command execution stopped with error(s)

do you have any idea why its not working when passing variables??

Thanks in advance
# 2  
Old 06-18-2007
Code:
        line= tail -$lineCount /tmp/MSISDNs | head -1

looks wrong

how about

Code:
        line=`tail -$lineCount /tmp/MSISDNs | head -1`

# 3  
Old 06-18-2007
Thanks alot for your reply porter.
I tried it and still the same, If i tested the value of the variable before or after calling the application i can get the right value. but still unable to pass it to the application.

Thanks
# 4  
Old 06-18-2007
What shell are you using?
# 5  
Old 06-18-2007
Code:
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 /tmp/MSISDNs | head -1)

        /opt/msp/opt/SAmsp/bin/prosubm_add -ms "$line" -hs off -ug postpaid -saa off  -v

        ((lineCount=lineCount-1)) 

done

#

# 6  
Old 06-18-2007
Thanks alot guys.
Im using KSH, but as reborg mentioned, it worked seems I forgot the semi colon.
Thanks alot for all your help guys.
 
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

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 ... (2 Replies)
Discussion started by: Grueben
2 Replies

6. 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

7. 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

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