Help please with FTP timer script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Help please with FTP timer script
# 1  
Old 11-06-2012
Help please with FTP timer script

Hi

Could somebody please help me with this code?

------------------------------------------
Code:
@ftp -i -s:"%~f0"&GOTO:EOF
open mysite.co.uk
myusername
mypassword
!:--- FTP commands below here --- 
cd public_html/ 
binary 
lcd c:\ 
put myfile.jpg
bye

---------------------------------------------
At the moment I execute the above FTP code as a batch file to transfer a single file from a local folder to my server, it does this once and then stops.

What I am searching for is a modification to the code so that it continuously transfers the same file every 10 seconds or so without having to re-start the batch file. I would then execute/kill the batch file with a schedule.

I already have "Script Ftp" which does exactly what I'm asking, but as this is a learning curve I'd really like to use script and do it myself if possible.

Any help would be appreciated.

Moderator's Comments:
Mod Comment edit by bakunin: which part of the numerous callings to use CODE-tags was not understandable?

Last edited by bakunin; 11-06-2012 at 05:11 PM..
# 2  
Old 11-06-2012
Quote:
Originally Posted by dobbies
I'd really like to use script and do it myself if possible.
See the man page for your favourite shell on how to put this into a while-loop. As you want to "do it yourself" you sure appreciate if i don't tell you how this is done.

If you can afford longer intervals on the transfer (1min or more instead of 10 seconds) you could use "cron"s services instead of the loop. Write a script and put that into crontab (see "man crontab" for details).

I hope this helps.

bakunin
# 3  
Old 11-07-2012
Thank you for your reply bakunin and I appologies for my mistake.

My comment "this is a learning curve" and "do it myself" meant that I would like to learn something about scripting with the help of others using this forum, and learning from examples of code to understand how they work. As I stated, at the moment I'm using a third party software namely "Script FTP" to do the work for me.

I have no idea about scripting and that's why I posted in this section "Unix for dummies".

If somebody could help me edit the code I submitted or point me in the direction of finding some that would do what I want and how to execute it, I would be very grateful.

The reason for the 10 second continuous upload is for a live webcam.

Many thanks
# 4  
Old 11-07-2012
No problem.

To learn shell scripting is complex and easy at the same time. It is complex because shell scripting is a programming language and it has to be learned like any other programming language. This is too much information to be passed to do so in a forum by exchanging postings. Buy a good book and read that, we have even a list of recommendable books in the forum. My personal favourite for learning the "Korn Shell", one of the most common shells there are, is

Barry Rosenberg, Hands-On KornShell93 Programming


Yet, script programming is easy because basically every command you enter on the command line could be put into a simple text file and then executed as script. Example:

You enter at the command line "ls -l" to list the directory content. Now let us turn this into a script:

Code:
#!/bin/ksh

ls -l

put that into a file called "myscript.sh", make it executable by issuing:

Code:
chmod 754 myscript.sh

and then execute it:

Code:
./myscript.sh

That is all - you have written your first script. Some details need explanation, though: you probably notice the first line. This simply tells the system, when executing the script, it should load this specific shell "/bin/ksh" first and execute the script with it. You can leave this line out but a Unix system can have several different shells installed and if you want control over which one it uses for your script you will want to make that clear by this first line.

If your system doesn't have "/bin/sh" replace it with any other shell. A script that basic will probably be executed by every shell. Still, if you pick a shell you should select one which is POSIX-compatible and common, which leaves 2 shells foremost: Korn shell (ksh) and Bourne again Shell (bash). Of these two i prefer "ksh", but this is at least partially personal preference.

To your problem: what you showed as "script" is basically some ftp-script. "ftp" is the client side of the "file transfer protocol" and a client-/server- software which implements that. "ftp" is interactive and can take commands from the user while it runs. The "script" is simply a list of such commands. To the shell this is only one command (the "ftp" itself). As i told you above you can put this into a script just the way you issue it on command line.

I hope this helps.

bakunin
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Looping in the shell script with help of script timer.

Hello Experts- We are facing some issues in the while loop script when we use the script time to decide whether to exist from the loop or continue. Below is the script SrcExitLoop="FALSE" Src_InitialStartTime=`date +%s` Src_StartTime=`date +%s` Src_NUM_ALERTS=0 TOTAL_ALERTS=`expr <SOME... (4 Replies)
Discussion started by: Amey Joshi
4 Replies

2. UNIX for Dummies Questions & Answers

Shell Script / Timer

Hey folks, We already got a working Script running, but actually we gotta start it manually but at least we want to run it like every 30minutes 1time. Could anyone give it a shot? #!/bin/sh for i in A B C D E F G H I J K L M N O P Q R S T U V W X Z do ln -sv /x/$i/*/PDF/001-*.*... (1 Reply)
Discussion started by: Yjerith
1 Replies

3. Shell Programming and Scripting

Perl script timer on program launch

So I am attempting to get a short but complex perl script to be able to time out an application that I will launch from a command line. The terminal I use is MKS C SHELL and I am having trouble doing the a job spawn that will launch the application and keep time on it. I know you could do this... (1 Reply)
Discussion started by: vas28r13
1 Replies

4. Shell Programming and Scripting

60 second Timer with Shell Script

Please how can i display a 60 second active countdown timer in an echo message. (7 Replies)
Discussion started by: frankycool
7 Replies

5. Shell Programming and Scripting

Automated FTP script using .netrc to multiple FTP servers

Hi all, I'm using the following script to automated ftp files to 1 ftp servers host=192.168.0.1 /usr/bin/ftp -vi >> $bkplog 2>&1 <<ftp open $host bin cd ${directory} put $files quit ftp and the .netrc file contain machine 192.168.0.1 login abc... (4 Replies)
Discussion started by: varu0612
4 Replies

6. Shell Programming and Scripting

passing parameter to ftp script from output of another ftp

Hi, I have a ftp script which first gets all the file names and echo's the latest file. I'm using another ftp command sets to get the file name given by first ftp. The problem is the parameter is not accepted by second ftp. The error message i'm getting is > Rename Temp File calloc:ICMP... (5 Replies)
Discussion started by: ammu
5 Replies

7. Shell Programming and Scripting

Startup Script "run process with Timer"

Hi I have a script that execute every X minute for checking new files in a folder and converting to pdf. Is there any way to start this script automatically on linux startup?. I use sleep function in script with infinite loop. while do killall -u `whoami` -q soffice soffice... (0 Replies)
Discussion started by: zawmn83
0 Replies

8. Shell Programming and Scripting

Simple script? First timer...

Hey guys, I'm brand new to the bash scripting world, here's my issue.. When people SSH to my box, I'm wanting to use screen to monitor them if I so choose. So, I've created a new user: testing, and I've set its startup shell to /bin/myshell.sh whose contents read this: #!/bin/sh $me =... (4 Replies)
Discussion started by: poon
4 Replies

9. Shell Programming and Scripting

FTP script to FTP file to UNIX - Solaris

Hello, A couple of times per week, i receive emails notifications when files are available for processing. Currently i read these eamails with a java program and store the attachement on my C: drive and would now like to generate a PC script to send this file name up to UNIX-Solaris and... (3 Replies)
Discussion started by: bobk544
3 Replies

10. UNIX for Dummies Questions & Answers

script run timer

any of you guys have a script for measuring the run time of any given script, where you would sandwich your own script between the timer script or something? thanks! :) (2 Replies)
Discussion started by: mark_nsx
2 Replies
Login or Register to Ask a Question