Bash FTP Script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Bash FTP Script
# 8  
Old 06-25-2014
Quote:
Originally Posted by jimmyf
the contents of
Code:
list_file=` .csv`

is a .csv file
this doesn't make much sense...
If you want to use ftp and transfer all .csv files instead of 'put':
Code:
 mput *.csv

if the objective is somewhat different, you need to explain it a bit further, but this 'list_file' assignment doesn't make much sense...
# 9  
Old 06-25-2014
The script is not getting past the login negotiations part.
Code:
220 xxxx FTP server ready.
331 Password required for xxxx.
530 Login incorrect.
Login failed.
530 Please login with USER and PASS.
530 Please login with USER and PASS.
(local-file) (remote-file) 221 Goodbye.

I can manually login so I know the username and password are good. Strange one.

---------- Post updated at 05:35 PM ---------- Previous update was at 05:31 PM ----------

Quote:
Originally Posted by vgersh99
this doesn't make much sense...
If you want to use ftp and transfer all .csv files instead of 'put':
Code:
 mput *.csv

if the objective is somewhat different, you need to explain it a bit further, but this 'list_file' assignment doesn't make much sense...
This part of the script puts the file
Code:
put $list_file

Here is the whole script though
Code:
#!/bin/bash
HOST=scp file user@x.x.x.x
USER=user    
#PASSWD=passwd
cd /home/somedir
list_file=` .csv`


ftp -nv <<-!x
open $HOST
user $USER $PASSWD
cd  /somedir/
binary
put $list_file
bye
!x
exit 0

# 10  
Old 06-25-2014
I repeat: "scp ..." is not the host!

They are telling you to use SCP instead of FTP.

Your entire script would be
Code:
scp *.csv user@x.x.x.x

# 11  
Old 06-25-2014
Ok, I only did what was suggested. So I am back to where I started then before opening this thread.
# 12  
Old 06-25-2014
Quote:
Originally Posted by jimmyf
The script is not getting past the login negotiations part.
Code:
220 xxxx FTP server ready.
331 Password required for xxxx.
530 Login incorrect.
Login failed.
530 Please login with USER and PASS.
530 Please login with USER and PASS.
(local-file) (remote-file) 221 Goodbye.

I can manually login so I know the username and password are good. Strange one.

---------- Post updated at 05:35 PM ---------- Previous update was at 05:31 PM ----------


This part of the script puts the file
Code:
put $list_file

Here is the whole script though
Code:
#!/bin/bash
HOST=scp file user@x.x.x.x
USER=user    
#PASSWD=passwd
cd /home/somedir
list_file=` .csv`


ftp -nv <<-!x
open $HOST
user $USER $PASSWD
cd  /somedir/
binary
put $list_file
bye
!x
exit 0

So your HOST variable is scp file user@x.x.x.x which after the assignment is done sets HOST to scp.
Your PASSWRD is commented out:#PASSWD=passwd.
I think there're a couple (at least) things that needs to be fixed first.

Last edited by vgersh99; 06-25-2014 at 06:59 PM..
# 13  
Old 06-25-2014
Quote:
Originally Posted by jimmyf
Ok, I only did what was suggested. So I am back to where I started then before opening this thread.
Not quite. People have suggested you try this code:
Code:
scp *.csv user@x.x.x.x

If you have ssh, you also have scp. Have you tried it yet? Does it work for you? If not, in what way does it not work for you?
# 14  
Old 06-25-2014
Code:
ftp -nv <<-!x
open $HOST
user $USER $PASSWD
cd /home/somedir
binary
put $list_file
bye
!x

This is your ftp command. The red line tries to open an FTP connection to $HOST. Regardless of what you put in there, it's going to try and use FTP protocol (and in this case will fail since what you have is not a valid host name). You can't just put scp or ssh in there to use SSH.

To do that you need a different command, such as scp or sftp.

What people are suggesting is that you replace all of your ftp command with the scp command. So, your example script would look like:
Code:
#!/bin/bash
HOST=x.x.x.x
USER=user

cd /home/somedir

scp *.csv ${USER}@${HOST}

exit 0

 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to block first bash script until second bash script script launches web server/site?

I'm new to utilities like socat and netcat and I'm not clear if they will do what I need. I have a "compileDeployStartWebServer.sh" script and a "StartBrowser.sh" script that are started by emacs/elisp at the same time in two different processes. I'm using Cygwin bash on Windows 10. My... (3 Replies)
Discussion started by: siegfried
3 Replies

2. Ubuntu

Bash script for FTP download -Mysql

Hi guys, I recently managed to write up my working script, but now I have a problem. If the file isn't there in the remote server, my actual script jumps it and all ok, but I need something like this: Search file -> if there, then download -> if not, download next file in the list. Any... (7 Replies)
Discussion started by: virtus96
7 Replies

3. Shell Programming and Scripting

Ftp bash script appends to file using cron instead of coping new file

I have a bash script that is running a mysql query and creating a csv file with a time stamp. It then uploads that to a ftp server. Everything works great when I manually run it. But then I have a cron job set to run every monday, wednesday and friday at 5am est. When the cron job runs, it... (7 Replies)
Discussion started by: akallenberger
7 Replies

4. Shell Programming and Scripting

Bash script for new file in ftp folder

Hello, I'm trying to make a bash script that send me e-mail if there is any new file in my ftp folder. cat inotify.sh #!/bin/sh /usr/bin/inotifywait -e create \ -mrq /home/mrowcp | while read line; do echo -n "$line " >> /var/log/inotify.log echo `date | cut -d " " -f1-4` >>... (3 Replies)
Discussion started by: mrowcp
3 Replies

5. Shell Programming and Scripting

end of file error bash ftp script

Hello kind programmers :) I am a newbie and running into an error "line 28: syntax error: unexpected end of file" on the script shown below. Any help would be greatly appreciated. Thanks! #! /bin/bash if ($#argv <3) then echo 'Usage get_modis_snow ' echo 'ftp script for MYD10A2... (2 Replies)
Discussion started by: cmshreve
2 Replies

6. Shell Programming and Scripting

bash script for ftp-upload is not working

Hello everyone, sorry for the title, most of you must getting sick of reading something like this, but I haven't found a solution, although I found many threads according to it. I'm working on a bash script that connects to a network printer with ftp where I want to upload a pdf created... (3 Replies)
Discussion started by: le_mae
3 Replies

7. Shell Programming and Scripting

FTP script error in BASH

Hi All, I have a script which is supposed to connect to Windows machine and FTP a file into LINUX. Script is like below #!/usr/bin/sh ParamterFle=${1} //grepping all parameters BossFtpLog=${2} // assigning log file ftp -i -n host_name << EOF user1 password1 cd /drive1/drive2 get... (6 Replies)
Discussion started by: Raamc
6 Replies

8. Shell Programming and Scripting

My first FTP bash script - sweet!

Hey - thanks for reading this! I just finished my first bash script that will handle daily ftp downloads for me, but I'm certain it could use some improvement. Its job is to download IDX data from an ftp host (which is 24 hours behind) and I download a mix of *.txt.gz file and .tar files. ... (2 Replies)
Discussion started by: sitesbyjoe
2 Replies

9. Shell Programming and Scripting

simple bash script to ftp?

Hi all has anyone got a code snippet of how i can ftp a file automatically by running a simple bash script. I have 4 things IP address xx.xxx.xx.xx username=satnam domain = app.sample.ftp password= satnam_password Im not sure how to pull these all together to ftp a file? any ideas? (1 Reply)
Discussion started by: satnamx
1 Replies
Login or Register to Ask a Question