Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 723
  • Last Modified:

doubt in FTP comment

what is the equilent of
ftp -s:"D:\futureElectronics\temp\ftpcmd.txt" ftp.xxxxx.com
in unix

i am getting error of
ftp: s: unknown option
Usage: ftp [-v] [-d] [-i] [-n] [-g] [-k realm] [-f] [-x] [-u] [-t] [host]
above comment is working fine in windows.i want to run in linux
0
priyapratheep
Asked:
priyapratheep
  • 6
  • 3
  • 3
3 Solutions
 
TintinCommented:
Put the contents of ftpcmd.txt in  $HOME/.netrc and then use ftp like

ftp example.com

0
 
priyapratheepAuthor Commented:
i have to create .netrc in home directory?

can u explain little bit?
0
 
TintinCommented:
Whoops, I just remembered that .netrc is just for specifying the login details.

You can either script it, eg:

#!/bin/sh
ftp -in example.com <<EOF
user username pass
cd somedir
get file
quit
EOF

or if you want to keep the commands in a file, do

ftp -in example.com <`cat /path/to/ftpcmd.txt`



0
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
omarfaridCommented:

You should have a script call it myscript that will ftp file to remote server:

ftp remoteserver <<END
cd /dir
binary
put file
bye
END

If you want to send multiple files then replace put file with the following :

prompt
mput file*.*


- make this script executable:

chmod +x myscript

- For ftp to work without providing any username / password,  use .netrc file in the user's home directory (the one who will run the script). This file should not be readable by others i.e. use
chmod 400 .netrc

The entry in .netrc should be as below:

machine remoteserver
login remoteusername
password mypassword

remoteserver is the server which is the ftp server where you want to sent the file(s)
remoteusername is the remote user login name on the ftp server
mypassword is the password of the remote user on the ftp server

for more info about .netrc, please use man netrc
0
 
priyapratheepAuthor Commented:
I give userid and pwd details in ftpcmd.txt file

xxxx
yyyy
cd outbound_to_xxxsys
get future.csv
bye

this is my ftpcmd.txt file where i am giving all the details


my shell program is
#ftp -s:"/var/tomcat/webapps/ROOT/WEB-INF/classes/ftpcmd.txt" ftp.futureelectronics.com
ftp -in ftp.futureelectronics.com <'/var/tomcat/webapps/ROOT/WEB-INF/classes/ftpcmd.txt'


now i am getting error of

[root@newsor classes]# ./future_ele.sh
'AUTH GSSAPI': command not understood
'AUTH KERBEROS_V4': command not understood
KERBEROS_V4 rejected as an authentication type
?Invalid command
?Invalid command
Please login with USER and PASS.
Please login with USER and PASS.
Passive mode refused.  Turning off passive mode.
Please login with USER and PASS.


with this parameters (id and pwd etc) it is working fine in windows env...
0
 
TintinCommented:
xxxx
yyyy

need to be

user xxxx
pass yyyy
0
 
priyapratheepAuthor Commented:
thanks
some errors gone

now i am getting error of

[root@newsor classes]# ./future_ele.sh
'AUTH GSSAPI': command not understood
'AUTH KERBEROS_V4': command not understood
KERBEROS_V4 rejected as an authentication type
pls advice
0
 
priyapratheepAuthor Commented:
any suggestions?
0
 
omarfaridCommented:
did you try my solution?
0
 
priyapratheepAuthor Commented:
now i am trying this

 HOST=ftp.ttttt.com
 FTPUSER=xxxx
 FTPPASSWORD=yyyy
 ftp -n $HOST <<-EOF
 user $FTPUSER $FTPPASSWORD
 cd outbound_to_serialsys
 bin
 get future.csv
 bye
 EOF


program is working fine...but still i am getting error of
[root@newsor classes]# ./futureHan.sh
'AUTH GSSAPI': command not understood
'AUTH KERBEROS_V4': command not understood
KERBEROS_V4 rejected as an authentication type

why it is so?

what is the difference between ftp -n  and ftp -in?

 ftp -n $HOST <<-EOF in this what is the use of -EOF?


thanks
0
 
omarfaridCommented:
it is not secure to put the username and password in a clear text file like the script you are running.

The .netrc file is meant for protecting you from such thing. It's permissions should be 400 (which is read only for owner and nothing for others)
0
 
priyapratheepAuthor Commented:
Eventhough program is working fine I am getting error message of

AUTH GSSAPI': command not understood
'AUTH KERBEROS_V4': command not understood
KERBEROS_V4 rejected as an authentication type

Pls advice



0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

  • 6
  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now