1822350 Members
4769 Online
109642 Solutions
New Discussion юеВ

mput command

 
Siva_11
New Member

mput command

Hi,

I would like to do ftp of a complete directory. Also I should use "mput" to FTP the directory. But the mput command doesn't allow to "mput" a directory. If it is just a file it is working fine, but doesn't work for a directory. Is there any option I can use to "mput" a directory.

I can't do a tar and untar as on the ftp prompt "tar" doesn't work. Mean to say when I run FTP iam on the destination server where my directory needs to be copied.
I need to do this with a script. I can do this manully, But I want to write a script.

Thank you in advance.

Regards,
Siva
3 REPLIES 3
Steven E. Protter
Exalted Contributor

Re: mput command

Shoulds like you need shell access.

It might work like this:

ftp << EOF
userid
password
lcd
cd
mput *
mkdir
cd
lcd
mput *

EOF


Thing is, it would be much easier with shell access and a tar file. ssh or telnet over and then do tar xvf something.tar

You could also do it by setting up rcp or scp (from secure shell) and doing this from target system:

scp -rp /source targetost:/targetdir

Even if prompted for a password this would do the job with less code and more securely.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Bill Hassell
Honored Contributor

Re: mput command

ftp is not a shell. It is a multiplatform file transfer program and the complete list of commands supported by the client is found with the ? command. The server's ftp may not support all of the client's commands. So while mput * looks like it might work with multiple directories and their contents, there are a huge number of compatibility issues. Some mainframes do not have hierarchical directories and others do. There is no option in mput to control descending into lower level subdirectories.

So ftp does not transfer anything except files. Directories must be individually created. Your script will have to determine what directories need to be created, then run ftp to create them, followed by ftp to cd to each directory, use mput * to send all the files and repeat as needed.


Bill Hassell, sysadmin
Muthukumar_5
Honored Contributor

Re: mput command

Ftp is called file transfer protocol to transfer the file's format. mput is used to put multiple files on the destination server. If you want to tranfer the files which is under /tmp/ directory then,

ftp server
ftp> user
ftp> mkdir /tmp/test/
ftp> mput /tmp/*

where * used to select every file.

If you do like this, every file under /tmp/ get selected and prompt's for permission.


We can do shell operation's with ftp easily as,


ftp> !

examample>

ftp> !touch /tmp/testfile;tar -cvf /tst.tar testfile

Else, go to the shell prompt from ftp prompt as,



ftp> !
$
$ exit
ftp>

you can do this on local shell.


If you want to make it in a script then,


------ /tmp/scriptfile ----
user test passwd
lcd /tmp/test/
!tar -cvf test.tar "*.c"
put test.tar
bye
---------------------------


ftp -i -n
Else as,


ftp -i -n <<-EOF
user test passwd
lcd /tmp/test/
!tar -cvf test.tar "*.c"
put test.tar
bye
EOF

HTH.
-Muthu




Easy to suggest when don't know about the problem!