Help Simple FTP Script Here Syntax


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help Simple FTP Script Here Syntax
# 1  
Old 04-16-2013
Wrench Help Simple FTP Script Here Syntax

I have a list of IP address and want to be assess whether FTP is allowing
FTP access. I don't want to use lousy NT shell, but cannot get the syntax down on this. ftphosts.txt is a simple list of IP adresses.
I want to iterate through the IPS and do a simple

ftp IPadress
user ftp password test@abc.org
Then lcd to c:\investigate and get all the files in the root.
Please help me with this syntax. I am running this in a Cygwin bash shell.
Thak you in advance for your help!
Gregg Dotoli

Code:
#!/bin/bash -vx
for g in `cat ftphosts.txt`; do echo $g
ftp -u $g<<++EOT++
user ftp ftp@anonymous.com
bin
lcd c:\investigate
hash
bell
mget *.*
user <ftp> <ftp@aol.com>
bin
mget  *.*
quit
++EOT++


Last edited by Corona688; 04-16-2013 at 12:19 PM..
# 2  
Old 04-16-2013
for x in `cat file` is a useless use of cat and dangerous use of backticks and much better written as a while read loop.

Code:
#!/bin/bash -vx
while read g
do
echo $g
ftp -u $g<<++EOT++
user ftp ftp@anonymous.com
bin
lcd c:\investigate
hash
bell
mget *.*
user <ftp> <ftp@aol.com>
bin
mget  *.*
quit
++EOT++
done < ftphosts.txt

I'm not sure the FTP syntax is right, but that is harder to check -- I can't run it on your FTP after all...
# 3  
Old 04-16-2013
Thank you for coding tips but the problem wasn't adressed

Thank you for the security advice, but the cat worked.
It is the FTP here syntax I needed help with.

Does anyone see the problem with this here syntax?

Thank you.
Gregg Dotoli
Smilie
# 4  
Old 04-16-2013
It's not a 'security problem', it's something that will blow up in your face someday.

What does the here-document do? The syntax is fine, but the contents may not be; in what way does it not work? Be specific. I can't see your computer from here, and don't have cygwin's own FTP client to test with.
# 5  
Old 04-16-2013
What is the here function?

Thank you for your help, but if you don't know what here is, you can't be
of help. I think it may not be such a challange for another.

Thank you.
Gregg
# 6  
Old 04-16-2013
If you refuse to cooperate with the people trying to help you, this thread will be closed. We are not mind readers, nobody can work in a vacuum.

What does your script do? Be specific.
# 7  
Old 04-16-2013
FTP Script

Code:
#!/bin/bash -vx
while read g
do
echo $g
ftp -i $g<<++EOT++
user ftp ftp@anonymous.com
lcd c:\investigate
hash
bell
bin
mget *.*
quit
++EOT++
done < ftphosts.txt

The file ftphosts is read into the $g variable. The problem is echoing ftp and anonymous at the name and password prompt. The here section between ++EOT++ and ++EOT++ should echo
username and password, then turn hash on, bell and binary before pulling down all the files into
c:\investigate. How do I get the user and password to be passed to the FTP servers?

Thank you in advance.
Gregg Dotoli


Last edited by Franklin52; 04-20-2013 at 11:09 AM.. Reason: Please use code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

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
Login or Register to Ask a Question