Posts

Showing posts with the label python

Automating tasks using Python for sending files through SFTP

Scheduled background tasks are a staple of IT world. For example, some things (programs) should be done in a certain time in each day,  or some procedure should be run a few times in an hour. In this we will discuss how to send a file to another server using SFTP. Crontab Most of the time, background tasks are triggered using UNIX-like crontab, there are some alternatives as well but lets say it is out of current post's scope. The crontab entry usually calls a shell script that in its own triggers other program, such calling a  web site using wget or curl, or invoking application command (php yiic commandname).  The existing crontab entry for sending the file to another server uses a shell script to prepare the files, create control files, and sending them across the network using sshpass with input redirection. The Challenge The problem we're facing is that sometimes the remote server doesn't respond normally. The cause is still unknown, and after getting incomplete file...