LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-28-2004, 11:42 AM   #1
wswartz
Member
 
Registered: Nov 2003
Posts: 56

Rep: Reputation: 15
Need help writing a script


I need a simple script to do some testing and I'm in a bit of a hurry. Normally I'd read up on it so as to "learn to fish". But I don't think I have time for that right now so I'm hoping someone can "give me a fish"; if you know what I mean.

I'm doing some network testing and need to put some real world traffic on the network. I thought of having two pc's, one with an FTP server and another getting a file off the server. I imagine this would be a simple bash script that would do the following at the client:

1. Get a file from the FTP server.
2. When done, delete the file and go back to step 1. (and repeat forever)

That's it! Not knowing much about bash, is this something simple? Can commands be pushed into FTP tp perform such functions from bash?

Let me know if someone can help.

BS
 
Old 04-28-2004, 11:50 AM   #2
hw-tph
Senior Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 58
You can use the expect command to do this, in fact scripted FTP sessions is one of the most common usages for expect.

It is *very* simple to start out with it. Either simply google a bit, or use the autoexpect script that comes with it to create a script automatically (it catches input and output and creates a script). You can then call this script from a bash script in a loop of some sort.


Håka
 
Old 04-28-2004, 12:00 PM   #3
hw-tph
Senior Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 58
Oh, and another solution would be using wget. Probably even simpler:
Code:
#!/bin/bash
x=0						# counter
while [ $x -lt 1000 ]
do
	wget ftp://user:password@hostname/path/to/file
        rm -f file
	let "x += 1"			# increase count
	echo "That was try number $x"
done
This would retrieve and delete the file a thousand times as fast as possible. You could add a sleep call after the echo to pause a second or so if you wish.


Håkan
 
Old 04-28-2004, 03:35 PM   #4
wswartz
Member
 
Registered: Nov 2003
Posts: 56

Original Poster
Rep: Reputation: 15
Thank you very much for writing the script out for me. In the spirit of learning I will check out the reference to "expect", but appreciate your assistance.

BS
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
help with writing a script jedimastermopar Linux - General 10 05-02-2005 01:34 PM
help writing script willinusf Programming 7 07-20-2004 11:37 AM
Help writing a rm script VisionZ Linux - Newbie 17 03-24-2004 07:15 AM
Help Writing a script. teeth44 Programming 2 10-14-2003 12:00 PM
writing a Script spanky5125 Linux - Security 5 01-08-2002 09:22 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:43 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration