LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-09-2008, 02:50 AM   #1
ust
Senior Member
 
Registered: Mar 2003
Location: fasdf
Distribution: Debian / Suse /RHEL
Posts: 1,130

Rep: Reputation: 31
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
 
Old 09-09-2008, 02:55 AM   #2
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
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}"
 
Old 09-09-2008, 03:47 AM   #3
ust
Senior Member
 
Registered: Mar 2003
Location: fasdf
Distribution: Debian / Suse /RHEL
Posts: 1,130

Original Poster
Rep: Reputation: 31
Quote:
Originally Posted by i92guboj View Post
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
 
Old 09-09-2008, 11:40 PM   #4
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
Quote:
Originally Posted by ust View Post
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?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
DIR parameter mcamember Linux - Newbie 8 12-22-2006 11:49 PM
linux bash - how to use a dynamic parameter in shell parameter expansion expression nickleus Linux - General 2 08-21-2006 04:54 AM
Unable to add parameter to /proc twk Red Hat 2 08-19-2006 10:52 AM
Which parameter to use...? FrogGuy Linux - Hardware 2 11-19-2005 08:25 PM
how to add -h parameter in script yulitao Programming 4 03-23-2004 07:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration