Pages

Wednesday, January 21, 2009

Using Windows XP Task Scheduler to Automate an FTP Upload

I recently came across a problem where I needed to schedule the daily FTP upload of a set of files to one of my client’s FTP servers. I was a bit out of my element and found that locating a solution to this task was surprisingly challenging. I thought I would post the steps here so that someone in a similar situation might benefit from the time I spent in trial and error.

1. My first goal was to make sure I could upload via ftp using the command prompt in Windows XP. I created the following script, ftp_script.txt, which I placed in a scripts folder on the C drive:

open www.yourhostname.com
username
password
put c:\test.txt test.txt
quit

Plug in your corresponding hostname, username, password, and file locations. This script will upload the local copy of test.txt to the server. The above script can be passed into your command line ftp client. Open up your command prompt and type:

ftp -s:path_to_script\scriptfile

Which, in my case, was:

ftp -s:c:\scripts\ftp_script.txt

The “-s” allows you to specify a file name in order to pass your username, password, and put commands to the command line ftp client.

2. If you get Step 1 working, the next step is to create a command file to run the ftp script. The command file is just a text file with a .cmd extension that calls up the command line ftp. In my case, I created ftp.cmd with the contents:

ftp -s:c:\scripts\ftp_script.txt

Test your command file by double clicking it to make sure that it executes the FTP successfully.

3. Finally, create a daily task using the Windows Task Scheduler. Go to Start > Control Panel > Scheduled Tasks (in Classic view). Click Add Scheduled Task and when it prompts you for the application, browse to your command file that you created in Step 2. As you finish out the task scheduler, you’ll get to choose how often you want the task to run and at what time.

After you complete these steps, your ftp job should be ready and waiting for its next scheduled execution time. I hope you find this trick as useful as I did!

(from: http://www.isinc.com/2008/11/19/using-windows-xp-task-scheduler-to-automate-an-ftp-upload/)

Automate windows-based applications

AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting. It uses a combination of simulated keystrokes, mouse movement and window/control manipulation in order to automate tasks in a way not possible or reliable with other languages (e.g. VBScript and SendKeys). AutoIt is also very small, self-contained and will run on all versions of Windows out-of-the-box with no annoying "runtimes" required!

AutoIt was initially designed for PC "roll out" situations to reliably automate and configure thousands of PCs. Over time it has become a powerful language that supports complex expressions, user functions, loops and everything else that veteran scripters would expect.

Features:

  • Easy to learn BASIC-like syntax
  • Simulate keystrokes and mouse movements
  • Manipulate windows and processes
  • Interact with all standard windows controls
  • Scripts can be compiled into standalone executables
  • Create Graphical User Interfaces (GUIs)
  • COM support
  • Regular expressions
  • Directly call external DLL and Windows API functions
  • Scriptable RunAs functions
  • Detailed helpfile and large community-based support forums
  • Compatible with Windows 95 / 98 / ME / NT4 / 2000 / XP / 2003 / Vista / 2008
  • Unicode and x64 support
  • Digitally signed for peace of mind
  • Works with Windows Vista's User Account Control (UAC)

AutoIt has been designed to be as small as possible and stand-alone with no external .dll files or registry entries required making it safe to use on Servers. Scripts can be compiled into stand-alone executables with Aut2Exe.

Also supplied is a combined COM and DLL version of AutoIt called AutoItX that allows you to add the unique features of AutoIt to your own favourite scripting or programming languages!

Best of all, AutoIt continues to be FREE - but if you want to support the time, money and effort spent on the project and web hosting then you may donate using the link to your left in the menu.

Take me to the downloads page!

Getting data back from a corrupted flash drive?

Don't trust Flash drive 100%!

Flash drives by nature are not reliable media. Never store data on flash drives you cannot risk to lose. Always make a back up. Some brands are better than others, but static RAM storage by nature is not 100% reliable. Some brands are notorious for unrelaibility - Sandisk cruiser is one of those brands to avoid.

If your flash drive "wigs out", you may be able to restore functionality, however data recovery in most cases will be catastrophic. A frequent loss of data on flash drives is the corruption of the boot sector in the static RAM. Because Windows operating systems treat flash drives like "mini" hard drives, essentially what you have is a corrupted hard disk which must be reformatted to recover functionality.

Before attempting a format, see if the drive can be read in another computer. If it can, great! Attempt to move the data off to salvage. If not, flash drive errors can also be caused by bad or corrupted drivers on the host computer. Not all flash drives export drivers to Windows or the drivers are local. Try to download the driver (if any) for your flash drive from the manufacturer. Then attempt to re-seek your drive.

(from: http://www.techspot.com/vb/topic45834.html)

You Can Still Fix Corrupted Flash Drive (hopefully)!

Recently someone came to me with a flash drive that said that it was not able to be accessed because the file system was corrupted. Does this mean their data is gone forever? No it simply means that Windows can't figure out what to do with the drive and files without the file system being fixed.

Well there are two ways to do this, there is a simple way through the windows menus (sometimes doesn't work) and then a command line way that works more often. I will show you how to do both methods so you can fix this issue.

First you will want to plug in the USB stick and try to open it through "My Computer" if you get a popup box that says something like can not open drive file system corrupted or along those lines then this tutorial is for you. Now if your drive doesn't show up or it says Drive (letter) inaccessible then that is a different issue and this tutorial won't help.

First way to fix this is the most basic method and I would say try this way first; if it won't work then move on to the second method (command line). I do not have a good answer to why the graphical user interface method sometimes fails, but if it does you can always go to the command line method. So first step is to go to "My Computer" and find the drive letter and right click on it. In the drop down menu that will popup you will want to click on the last option that says "properties". In the Properties dialog box you will want to choose the Tools Tab. In this tab you will want to run the Error-checking tool, there is a button that says Check Now... click this. In the new window you will want to check mark both options (automatically fix file system errors) and (scan for and attempt recovery of bad sectors).

The program should run through and if there are any sectors or issues with the file system or boot sectors it will fix them for you. If the program says it completed successfully then you can try to open your flash drive, if you are successful then you are done. If the program just blinks and then stops and never prompts you that it has finished then it didn't work and you need to move on to the command line method.

Command Line Rescues Damaged Flash Drive

The command line method will seem way more complicated and intense but it really isn't. All you will need to do is go to "Start" and choose "Run". In the text box that comes up you will want to type "cmd" and hit enter. This will open a command line text prompt that we will use to fix our flash drive.

In the new window you will want to type chkdsk this is for checking the disk, and then we have to enter some parameters so the computer knows what to do to the flash drive. The next thing you will want to type is the drive letter of your USB device; you can find this by going to "My Computer" it will be next to the drive in the window. Once you have both of these then we will put our parameters to fix the drive, the two we will use are \f and \r.

The /f Fixes errors on the disk. The disk must be locked. If chkdsk cannot lock the drive, a message appears that asks you if you want to check the drive the next time you restart the computer.

The /r Locates bad sectors and recovers readable information. The disk must be locked.

So now that we know what our commands do let me spell out the command line that you should have typed.

C:\>chkdsk E: \f \r

Now the one thing in this command that can change a lot is the letter of the drive, mine is E: yours could be almost anything from A to Z so check and be sure you get the right drive letter.

Once you have the command line text entered correctly then you can hit enter and it will run through and fix the file system on your Flash drive. Once it is done then you can check to be sure it worked. Once it works you should be able to get to all the files on your flash drive and use them just as before.

(from: http://www.associatedcontent.com/article/290045/corrupted_file_system_on_a_usb_flash.html?page=2&cat=15 )
Stats