Help Simple FTP Script Here Syntax


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help Simple FTP Script Here Syntax
# 8  
The here-document is working fine. FTP is printing the command itself for whatever reason. Perhaps it doesn't like that form of login; that can depend a lot on the FTP server.

You may be able to create a ~/.netrc file for automatic login, with contents like
Code:
machine hostname
        login username
        password whatever

# 9  
My version of the ftp client seems to insist on reading the password from the terminal, not stdin, wondering if you have the same problem. .netrc works.
# 10  
Too many hosts for a .netrc

I already have the IP list, it's a huge amount of work and not very efficient to create a .netrc file. Is anyone out there good with the syntax of the HERE document? It's just a matter of syntax. The FTP servers all provide
the same login screnn and password prompt. It's pretty much a standard.

All I am trying to do is pass the same user ftp and password joe@test.com
to the script. It can't be this hard. I don't want to say anything but 5 messages ago you didn't know what a Here doc was. ANyone????

Thanks,
Gregg Dotoli
# 11  
Quote:
Originally Posted by gdotoli
I don't want to say anything but 5 messages ago you didn't know what a Here doc was.
You are vastly mistaken. I've been adept at shell scripting for many years.

It is certainly not as easy as you insist. My FTP client doesn't even wait for the 'user' command, it shows a prompt instantly, even when run from script. Even when I close all other file descriptors, it just opens /dev/tty to talk to the terminal directly.

And it may bear no resemblance to yours, because you're also refusing to answer any of my questions. Mine does not have '-u' for instance. It's not even clear whether you're using Windows FTP, Cygwin FTP, some third-party executable, or what at this point, there's many variants. If you don't answer questions, how am I to know if any of my suggestions ever worked...?

Even a screenshot of what happens when you run your program would be more productive than this entire thread so far.

You've refused to even try anything I've suggested, too. Even just knowing that .netrc works for one IP would tell me a lot more about your setup than I know right now.

Quote:
ANyone????
I'm not stopping anyone from posting in this thread... I think your attitude, and the complete and total lack of information from you, is doing that.

Last edited by Corona688; 04-16-2013 at 06:02 PM..
# 12  
After much experimenting I think the -n option may be needed in order to use the 'user' option, to prevent the FTP server from doing autologin. And the password may require quotes.

This works here:

Code:
ftp -n <<EOF
open hostname
user username "password"
ls
bye
EOF

# 13  
I solved the problem. I am using wget (gnu) in a while read loop. wget has the ability to authenticate without using another Unix command, it is built in. So everything works fine and is much cleaner.

Thanks,
Gregg

---------- Post updated at 03:10 PM ---------- Previous update was at 01:59 PM ----------

Iterating through the FTP IP Host file with the while read loop along with wget allows easy passing of username and password for checking technical evaluation of a list of ftp site.

while read g; do echo $g; wget -r ftp://ftp:fto@$g/ >>filelist;done<ftphosts.txt

There was no need for a here document.
This User Gave Thanks to gdotoli For This Post:
# 14  
You can make this more efficient by running wget only once, since it can accept a list of files via -I, and read stdin via -I -

Code:
while read g
do
        echo ftp://ftp:fto@$g/
done < ftphosts.txt | wget -I - >filelist

Since you have Cygwin though, your version of wget may be slightly odd, and may or may not support -I.
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #434
Difficulty: Medium
jQuery is a vanilla JavaScript library designed to simplify DOM-oriented client-side HTML scripting along with offering cross-browser compatibility.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Syntax in a simple script

I am in the process of writing a script. A very preliminary version is giving a syntax error. The script is #!/bin/bash #file1=’./data/heu/hout1’ exec 10<&0 exec < './data/heu/hout1' #file1=’./data/heu/hout1- i=1 j=0 while read file1 do echo $file1 echo $i if then... (3 Replies)
Discussion started by: ngabrani
3 Replies

2. Shell Programming and Scripting

Help with FTP Script which is causing "syntax error: unexpected end of file" Error

Hi All, Please hav a look at the below peice of script and let me know if there are any syntax errors. i found that the below peice of Script is causing issue. when i use SFTP its working fine, but there is a demand to use FTP only. please find below code and explain if anything is wrong... (1 Reply)
Discussion started by: mahi_mayu069
1 Replies

3. UNIX for Dummies Questions & Answers

Help syntax to restore partition from ftp

Hi, I found info on the internet to backup a partition to ftp. But I am unable to properly format the syntax to restore the partition. This is being done from a ssh logged in session to a server booted with a liveCD. backup: dd if=/dev/sda5 bs=2048 conv=noerror,sync | lftp -u user,passwd... (7 Replies)
Discussion started by: chang-li
7 Replies

4. Shell Programming and Scripting

Help making simple perl or bash script to create a simple matrix

Hello all! This is my first post and I'm very new to programming. I would like help creating a simple perl or bash script that I will be using in my work as a junior bioinformatician. Essentially, I would like to take a tab-delimted or .csv text with 3 columns and write them to a "3D" matrix: ... (16 Replies)
Discussion started by: torchij
16 Replies

5. UNIX for Dummies Questions & Answers

User ID syntax to FTP to Windows

Hello, I have searched the forums and may not be putting in the right keywords, but hopefully someone will be kind enough to help... It's been awhile since I've ftp'd to a Windows server, but no matter how I try to connect, it will not let me, although I have no issues setting up a connection... (1 Reply)
Discussion started by: tekster757
1 Replies

6. Programming

Tools for writing a simple syntax checker?

I'm trying to write a small utility for syntax checking. I've tried using Flex/Bison, but these seem too advanced for my task. A simpler tool would be appreciated. (1 Reply)
Discussion started by: Ilja
1 Replies

7. Shell Programming and Scripting

Simple script uploading *.dem files to an ftp

Hello.. i want to create a simple script that's upload all the *.dem files from one directory to ftp and then delete them. Any help? (3 Replies)
Discussion started by: TuXaKoS
3 Replies

8. UNIX for Dummies Questions & Answers

FTP - switching user syntax

Running the following shell script, #!/usr/bin/ksh set -x swdofile=/opt/SWDO_IN1V01P001_1.csv USER='myusername' PASSWD='mypassword' HOST='myhostname' ftp -n $HOST << SCRIPT quote USER $USER quote PASS $PASSWD su - BRA -c put $swdofile quit SCRIPT exit 0 but not managing to get the... (1 Reply)
Discussion started by: daveaasmith
1 Replies

9. HP-UX

Syntax problem with Unix ftp get command

An outside vendor has staged 2 batch files for us and I've tried to retrieve the files using the commands that they've indicated I could use to retrieve one file at a time. I've tried using this command in a shell script after a successful connection to their server: get "$$ ID=IL096869 BID='PGP... (2 Replies)
Discussion started by: mheinen
2 Replies

10. 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

Featured Tech Videos