LinuxQuestions.org
Help answer threads with 0 replies.
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, 12:42 PM   #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, 12:50 PM   #2
hw-tph
Senior Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 57
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, 01:00 PM   #3
hw-tph
Senior Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 57
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, 04: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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 02:34 PM
help writing script willinusf Programming 7 07-20-2004 12:37 PM
Help writing a rm script VisionZ Linux - Newbie 17 03-24-2004 08:15 AM
Help Writing a script. teeth44 Programming 2 10-14-2003 01:00 PM
writing a Script spanky5125 Linux - Security 5 01-08-2002 10:22 AM


All times are GMT -5. The time now is 04:02 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration