Example SFTP batch upload script for AS400 server to upload to a Unix SFTP server - sftp

Suppose I have a file called helloworld.txt on an AS400 and I want to write a script to automate the daily upload of the source file helloworld.txt on an AS400 server to upload to a Unix SFTP server, say sftp://exampleunixsftp.com?
Does someone have such a script? Is OpenSSH the only tool that can be used on the AS400 to get this accomplished or are there any other methods? If LFTP could be installed on the AS400, that would be an easy solution but since it's only for Unix/Linux/Win/Mac then I don't have this option. I read Scott Klement's article at:
http://systeminetwork.com/article/ssh-scp-and-sftp-tools-openssh
I just need an example basic script to get this done. I'd appreciate this.

The MidrangeWiki topic on SSH has some information and examples that may be helpful.
sftp is intended primarily as an interactive utility. scp performs the same function non-interactively.
The command, once authentication is set up, would simply be:
scp helloworld.txt username#exampleunixsftp.com:<destination path>
LFTP can be installed with some preparation in the PASE environment. See Open Source Binaries. Currently offline. Use the Google cache.

Related

Automated delete on SFTP server (PuTTY? WinSCP?)

I'm searching for a solution to easily delete files on a SFTP server automatically after a specific period of days.
I read something about automation via PSFTP from PuTTY and WinSCP. But there are no examples for deleting files...
With WinSCP, use the rm command with a filemask with a time constraint (to select only files with certain age, if I understand correctly, what you want to do).
E.g. to delete all files older than 5 days:
rm *<5D
For all the other instructions to assemble a script and schedule its run, see:
Automate file transfers (or synchronization) to FTP server or SFTP server
Schedule file transfers (or synchronization) to FTP/SFTP server
See also:
Documentation for the rm command;
Documentation for the file masks.
SFTP server is also a SSH server. Write a simple code in any language that you're comfortable with and schedule it with crontab.

Download a file from remote server in UNIX

I have a file on a remote server that I can connect to via ssh. I would like to copy the file from the remote server at the path: '/home/example.txt' to my computer's desktop.
Should I be using wget, sftp, ftp, or simply rm?
Bonus points if you know a good resource for UNIX documentation, since google's results were not great.
Use scp(1):
~$ scp user#host:/home/example.txt .
None of them, you should use scp
scp or rcp if you don't want/need to be secured. Or alternatively rsync will be nicer for anything more complicated with remote file transferring on a regular basis.
For the documentation, look at the man pages, ex: man scp. Or online at
http://linux.die.net/man/1/scp
http://linux.die.net/man/1/rcp
http://linux.die.net/man/1/rsync
Try Filezilla Utility
More info on http://filezilla-project.org/

Unix Shell script to copy files from unix location to windows FTP

Could anyone provide me Unix shell script to copy files from unix location to windows FTP location.
Thanks,
Chaitu
I'm going to assume you have access to the unix box. Sounds like a simple cron job using ftp. You'll need to review the crontab syntax to set that up. Check out this article on scripting FTP to get you started there.

Script to recursively look for a file on ftp server until it found

I just want to transfer a file from ftp server to unix folder, --this is stright forward.
if the file doesn't exist on the ftp server, then the script needs to run recursively until it finds the file. Please let me know how do i get that file.
please remember script has to run on ftp server.
Thanks
CK
I'd mount the FTP server with curlftpfs http://curlftpfs.sourceforge.net and then use it like it were a local file system — for example, run find(1).
You need to write a program to automate your FTP session. You can either write your own custom FTP client, not that hard if you know a few things about network programming, or write a script to automate a session for an existing client. For the latter approach, I suggest using Expect if you are proficient with TCL, or PyExpect if you prefer Python. Expect is a library designed to automate interactive tasks like downloading a file with FTP.

automate sftp upload process

I'm looking for a way to upload files/dirs structure from one server to another..
The only way it's possible in my case is SFTP upload, is there any easy way to upload it, using script or something without making archive of files/dirs, I want to recreate on remote server?
Thank you!
Perhaps a solution could be found using recursive scp (scp -r)? Or are you limited explicitly to sftp only?
There's also a client named lftp which has sftp and scripting support - much like batch file I would imagine - a list of ftp commands. (http://lftp.yar.ru/lftp-man.html)
You may want to consider Syncplify.me FTP Script! as a solution. It allows you to write very simple scripts to achieve your goal.
For example, uploading an entire directory to a remote SFTP server would actually be a single line of code added to one of the ready-made templates.
http://www.syncplify.me/products/ftp-script/
edtFTPj/PRO is a Java SFTP client that has a comprehensive scripting engine. Being Java you can run it on any platform where Java is supported.
Here's some more details on the scripting support. It has an 'mput' command that uploads all the files in the current directory to the remote directory.
Recursive transfers aren't yet supported, but could easily be added if required - email support if you are interested.

Resources