Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> H@H Server Automation for hathdl files

 
post Nov 12 2012, 11:32
Post #1
G Just G



Casual Poster
****
Group: Members
Posts: 414
Joined: 27-October 08
Level 177 (Lord)


Useful? I have no idea what Karma is for but you could hit the button.


Here's how to use WinSCP to do automation of Hathdl functions... These steps should work for Windows 7 machines where you're running as an administrator. You may need to tweak them to work for you. This is a great way to save some time and very much worth doing if you don't currently automate. It may or may not be easy to do and my steps may or may not be that clear. If you see an area that you don't understand or that is unclear send me a PM and I'll try to rewrite with more detail


Winscp is an Open source graphical SFTP client for Windows. With it you can setup a script to take files in one folder and place them in another folder on a different machine. In this case your Ubuntu server.

First off download winscp: [winscp.net] http://winscp.net/eng/download.php

install it and goto the folder where you installed it

create a file called sync1.txt at the bottom of this post copy my script into it... go ahead and take a look at the script

For me I keep my hathdl files (ON MY LOCAL COMPUTER) at the following location m:\H@H\hathdl ... you'll need to change that to wherever you want to put .hathdl files that you get when you use the hath downloader so perhaps you'll change m:\ to c:\ -- the lcd command means local change directory so you'll change all incidents to c:\ -- for some reason on my machine just doing lcd m:\H@H\hathdl doesn't work so I have to do each step.

option batch continue setup - winscp to continue whenever prompted with something like "would you like to replace this file?" and the like

Open Winscp and hit "New" enter the ip address for your server, the port (default is 22) that you use for SSL, and enter your username and password that you use to log on, hit Save and be sure to have it save the password you'll need to check a box for this.

you'll now have an entry in WinSCP called *username*@*IP Address* that's what you need to plugin to the "Open" line below option so that the script knows what connection it's trying to open

The next line starts with "call" - call is something you might type into linux -- these commands happen on your server and NOT on your local machine.

I have it create the directory that H@H uses to download files to ... you'll need to change it to whatever your account name is /home/tech/H@H is the folder I use for H@H on my server for you that folder will most likely be different... H@H has some default folders that get created when you run it - the ones that matter to you are the downloaded and hathdl folder you'll need to know the locations of those two folders on your server for this to work.

so you're making the downloaded folder that way if it somehow gets deleted (it will!) it'll be made BEFORE the hath downloader attempts to download anything.

line 7 uses the chmod 777 command - this sets the folder so ANYONE can write it... I've had issues where this hasn't happened correctly and winscp has failed... again you'll need to update the directory.


line 8 - put -delete M:\H@H\hathdl\ /home/tech/H@H/hathdl -- put any files on your LOCAL machine onto your server at the follow folder... and delete them from the local machine - its important to delete them so winscp doesn't send the file 30 times to your server.

line 9: making sure that the downloaded folder gets made - you might be able to delete this but I know my script in its current format works so just update the folder location and move on.

line 10 - get all the files your server has downloaded from the hath downloader and put them on your local machine

line 11 - making the downloaded folder again -- I'm paranoid just get over it.

line 12 - using the find command to DELETE anything older than one day - this prevent you from storing too many downloaded files on your server and running out of room ... also keeping it to one day is a smart move because winscp isn't really efficient at moving files.

line 13 - that -delete command WILL delete the downloaded folder as soon as its finished but ONLY if H@H isn't currently downloading files to it... so no worries if you're downloading files but when you're not its bad news. as such this line MUST be there do not skip this one.

line 14 - if the folder got deleted you need to set permission to let everyone write to it

line 15 - exits the script


Now to automate: On Windows do the following --- I got lazy format changed --

Start -> control panel -> administrative tools -> task scheduler -> left click "Task Scheduler Library" in the blank space in the top center right click and select create new task -> select Change User or Group type in "Network Service" hit "Check Names" and hit OK -> select the "Run whether user is logged on or not" circle -> goto triggers -> hit add -> Begin the Task: At log on -> Specific User -> Change User name -> your user name for example G -> Delay Task for 1 minute -> repeat task every 5 minutes for a duration of indefinitely -> Enabled -> click OK -> Goto Actions -> New -> Action: Start a program -> Program/script m:\winscp\winscp.com (you'll need to change this folder location for where you have winscp on your local machine) -> Add arguments /console /script=m:\winscp\sync1.txt -> hit OK -> goto settings tab -> "Allow task to be run on demand" -> "Run task as soon as possible after a scheduled start is missed -> "If the task is already running, then the following rule applies" Do not start a new instance ** YOU MUST DO THIS ** -> hit ok -> log off your computer and log back in... at this point it should all be working

You'll just want to place your .hathdl files on your local machine in your hathdl directory and after a while your server will download the hathdl files and winscp will retrieve them from the server...

[The Script]

lcd m:
lcd m:\H@H\
lcd M:\H@H\hathdl
option batch continue
open *username*@*IP Address*
call mkdir /home/tech/H@H/downloaded
call chmod 777 /home/tech/H@H/downloaded -R
put -delete M:\H@H\hathdl\ /home/tech/H@H/hathdl
call mkdir /home/tech/H@H/downloaded
get /home/tech/H@H/downloaded M:\H@H\downloaded
call mkdir /home/tech/H@H/downloaded
call find /home/tech/H@H/downloaded -mtime +0 -delete
call mkdir /home/tech/H@H/downloaded
call sudo chmod 7777 /home/tech/H@H/downloaded -R
exit

This post has been edited by G Just G: Nov 12 2012, 11:42
User is offlineProfile CardPM
Go to the top of the page
+Quote Post


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 


Lo-Fi Version Time is now: 4th May 2024 - 22:25