LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Add parameter (https://www.linuxquestions.org/questions/linux-newbie-8/add-parameter-668563/)

ust 09-09-2008 02:50 AM

Add parameter
 
I have a ftp script "script1" like this

#vi script1
ftp ip <<EOF
lcd dir1
cd dir2
put ${1}
! script2
bye
EOF


then I run it as
#script1 myfile

then it could ftp myfile to remote site , it works fine , that mean ${1} is the parameter

In the script1 , it will run another script ( script2) , now I would like this scripts also use the parameter , for example , I would like to display the parameter of ${1} like below , what can i do ?

I tried to edit script2 as below
#vi script2
echo ${1}

what I expect the result is myfile , but it didn't , can advise what can i do ? thx

i92guboj 09-09-2008 02:55 AM

I am not sure I understand you correctly, but nonetheless, if you call script2 from within script1, you need to pass it the argument, just like you pass it to script1.

Code:

#this is inside script1
./screen2 "${1}"


ust 09-09-2008 03:47 AM

Quote:

Originally Posted by i92guboj (Post 3274190)
I am not sure I understand you correctly, but nonetheless, if you call script2 from within script1, you need to pass it the argument, just like you pass it to script1.

Code:

#this is inside script1
./screen2 "${1}"


thx reply ,

what is screen2 ? is a command ?

thx

i92guboj 09-09-2008 11:40 PM

Quote:

Originally Posted by ust (Post 3274256)
thx reply ,

what is screen2 ? is a command ?

thx

Ouch, I meant "script2". That illustrates how to call script2 from within script1 passing $1 to script2. Isn't that what you intended?


All times are GMT -5. The time now is 03:34 PM.