Passing Arguments

Passing Arguments

Post by Chris Sh » Sun, 18 Aug 1996 04:00:00



I want to Pass an argument to a unix command.
For example. I get the shell script to go to FTP by just typeing FTP in
the Script.  Then I want the script to execute one of the commands in FTP
But I can't get it to work.
An example script that I made.
#!/bin/sh
ftp
open miso.wwa.com
Other commands
quit

That does not work
Can someone please help me
Please e-mail me.

 
 
 

Passing Arguments

Post by Chris Sh » Sun, 18 Aug 1996 04:00:00


I want to Pass an argument to a unix command.
For example. I get the shell script to go to FTP by just typeing FTP in
the Script.  Then I want the script to execute one of the commands in FTP
But I can't get it to work.
An example script that I made.
#!/bin/sh
ftp
open miso.wwa.com
Other commands
quit

That does not work
Can someone please help me
Please e-mail me.

 
 
 

Passing Arguments

Post by Mohit Ar » Tue, 20 Aug 1996 04:00:00



>   I want to Pass an argument to a unix command.
>   For example. I get the shell script to go to FTP by just typeing FTP in
>   the Script.  Then I want the script to execute one of the commands in FTP
>   But I can't get it to work.
>   An example script that I made.
>   #!/bin/sh
>   ftp
>   open miso.wwa.com
>   Other commands
>   quit

The above does not work because each of the commands above is seen by the
shell and not by ftp - that is, open .. etc commands should be interpreted by
ftp and not by the shell. So try this:
#!/bin/sh
ftp <<EOSM
open miso.wwa.com
Other commands
quit
EOSM

--

Department of Computer Science          smail:  6500 South Main #310  
Rice University                                 Houston, TX-77030    
phone: (713) 527-8750 (x3831)                   phone:  (713) 630-9221        

 
 
 

Passing Arguments

Post by Sherwin Anthony Sequei » Wed, 21 Aug 1996 04:00:00




Quote:> I want to Pass an argument to a unix command.
> For example. I get the shell script to go to FTP by just typeing FTP in
> the Script.  Then I want the script to execute one of the commands in FTP
> But I can't get it to work.
> An example script that I made.
> #!/bin/sh
> ftp
> open miso.wwa.com
> Other commands
> quit

You need what is called a 'here document'.  Each line in your script
above is taken as a shell command, which is not what is required.

Here is an example based on your script:

#!/bin/sh
ftp<<-EHD
open miso.wwa.com
Other commands
quit
EHD

All text between the <<-EHD and EHD is taken as stdin to ftp.  EHD can
be any string.   The hyphen ('-') allows you to indent text in between
the 'labels' (with TABS only).  The end label must be on a line by
itself.

Quote:> That does not work
> Can someone please help me
> Please e-mail me.

Luck!
--
Tony Sequeira
 
 
 

Passing Arguments

Post by Fabrice Anni » Thu, 22 Aug 1996 04:00:00



> I want to Pass an argument to a unix command.
> For example. I get the shell script to go to FTP by just typeing FTP in
> the Script.  Then I want the script to execute one of the commands in FTP
> But I can't get it to work.
> An example script that I made.
> #!/bin/sh
> ftp
> open miso.wwa.com
> Other commands
> quit

> That does not work
> Can someone please help me
> Please e-mail me.

this question should be in a FAQ.
Here is an example of non interactive ftp :

ftp -i -v -n theserver <<!EOF
user mylogin mypassword
put myfile
bye
!EOF

where :
  'theserver' is the name of the server
  'mylogin' and 'mypassword' is a login-name and password you know
  'myfile' is the name of the file you want to transfert

 
 
 

Passing Arguments

Post by Kenny Whitake » Fri, 23 Aug 1996 04:00:00





>> I want to Pass an argument to a unix command.
>> For example. I get the shell script to go to FTP by just typeing FTP in
>> the Script.  Then I want the script to execute one of the commands in FTP
>> But I can't get it to work.
>> An example script that I made.
>> #!/bin/sh
>> ftp
>> open miso.wwa.com
>> Other commands
>> quit

>You need what is called a 'here document'.  Each line in your script
>above is taken as a shell command, which is not what is required.

>Here is an example based on your script:

>#!/bin/sh
>ftp<<-EHD
>open miso.wwa.com
>Other commands
>quit
>EHD

>All text between the <<-EHD and EHD is taken as stdin to ftp.  EHD can
>be any string.   The hyphen ('-') allows you to indent text in between
>the 'labels' (with TABS only).  The end label must be on a line by
>itself.

>> That does not work
>> Can someone please help me
>> Please e-mail me.

>Luck!
>--
>Tony Sequeira

--
It sounds like what you need is a .netrc file. THe .netrc would like like this:

open miso.wwa.com
user your userid your password
Other commands
quit

Since your password is in the .netrc, be sure to restrict the permissions.
Then when you ftp the command would be:
ftp -nv < .netrc

Kenny Whitaker

 
 
 

1. script questions - passing argument as argument to another program

Hello.

I have a script that I want to take an argument and pass it to the
passwd program.

1.  How in any situation do I take an argument in a script and pass it
to a program?  I can type the command in like: passwd $1 , but I do
not know how to simulate the enter key being pressed at that point.

2.  How do I allow other users to run this script?  I want the script
itself to execute as root when run since there are commands only root
may run, and I will only give other people in a certain group the
ability to execute the script.

3.  Is there a way to associate a file with multiple groups?

Thank you for your time.

Andrew

please remove 'REMOVE' characters to e-mail me

2. Solaris 2.7/SPARC and JDK 1.4.0 and libCrun.so.1 problem

3. How to pass arguments passed in ''s

4. inn 1.4 posting *almost* there

5. Passing arguments from the form via BASH script

6. Assertion error in /lib/ld-linux.so.2

7. passing arguments to an alias

8. need help with X startup

9. passing arguments with spaces in Bourne shell script

10. passing argument to handler

11. Passing arguments to kernel at boot

12. Passing arguments to X when using graphical login

13. #! files passing arguments to their interpreters