Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Help please with FTP timer script Post 302728061 by bakunin on Wednesday 7th of November 2012 09:50:09 AM
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
 

10 More Discussions You Might Find Interesting

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

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

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

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

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

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

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

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

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

10. 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
SIMPLEFTP(1)						    InterNetNews Documentation						      SIMPLEFTP(1)

NAME
simpleftp - Rudimentary FTP client SYNOPSIS
simpleftp url [...] DESCRIPTION
simpleftp is a Perl script that provides basic support for fetching files with FTP in a batch oriented fashion. It takes one or more FTP URLs on the command line. The file(s) will be retrieved from the remote server and placed in the current directory with the same basename as on the remote; e.g., <ftp://ftp.isc.org/pub/usenet/CONFIG/active.gz> is stored as active.gz in the current directory. The script properly understands usernames, passwords and ports specified as follows: ftp://user:password@host:port/path/file BUGS
simpleftp is an extremely poor substitute for more complete programs like the freely available wget or ncftp utilities. It was written only to provide elementary support in INN for non-interactive fetching of the files in <ftp://ftp.isc.org/pub/pgpcontrol/> or <ftp://ftp.isc.org/pub/usenet/CONFIG/> without requiring administrators to install yet another package. Its shortcomings as a general purpose program are too numerous to mention, but one that stands out is that downloaded files by simpleftp override existing files with the same name in the local directory. HISTORY
Tossed off by David C Lawrence <tale@isc.org> for InterNetNews. Rewritten to use "Net::FTP" by Julien Elie. $Id: simpleftp.pod 8357 2009-02-27 17:56:00Z iulius $ SEE ALSO
actsync(8). INN 2.5.2 2009-05-21 SIMPLEFTP(1)
All times are GMT -4. The time now is 12:57 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy