' . __('By', 'thematic') . ' '; if ( thematic_is_custom_post_type() && !current_theme_supports( 'thematic_support_post_type_author_link' ) ) { $author_info = ''; $author_info .= get_the_author_meta( 'display_name' ) ; $author_info .= ''; } else { $author_info = ''; $author_info .= sprintf('%s', get_author_posts_url( $authordata->ID, $authordata->user_nicename ), /* translators: author name */ sprintf( esc_attr__( 'View all posts by %s', 'thematic' ), get_the_author_meta( 'display_name' ) ), get_the_author_meta( 'display_name' )); if(get_the_author_meta( 'twitter' )!='') $author_info .= ' [Twitter]'; if(get_the_author_meta( 'googleplus' )!='') $author_info .= ' []'; $author_info .= ''; } $author_credit = $author_prep . $author_info ; return apply_filters('thematic_postmeta_authorlink', $author_credit); } function add_post_thumb($title) { return get_the_post_thumbnail(NULL, 'thumbnail') . $title; } add_filter('the_content', 'add_post_thumb'); FTP from the Windows XP command line

FTP from the Windows XP command line

FTPSometimes I discover some new… old part of Windows ­čśÇ
I did some research on Google to learn how to download a file daily, via FTP, and now I know that Windows has a little FTP client (named, with a lot of fancy, ftp.exe) that can do everything a “normal” FTP client like FileZilla or CuteFTP can do.

It hasn’t a graphical interface, the only way to use it is from the command line, and so it’s perfect to be scheduled, to execute repeated tasks. This is how I programmed Windows to accomplish my need:

– I created a new text file (next I renamed it “ftp.bat“)┬áwith the following text:
@ECHO OFF
echo open ftp.mydomain.com >> D:\Backup\script.txt
echo mylogin >> D:\Backup\script.txt
echo mypassword >> D:\Backup\script.txt
echo lcd D:\Backup >> D:\Backup\script.txt
echo prompt >> D:\Backup\script.txt
echo mget %DATE:~8,2%%DATE:~3,2%%DATE:~0,2%*.psc >> D:\Backup\script.txt
echo bye >> D:\Backup\script.txt
echo ftp -s:D:\Backup\script.bat >> D:\Backup\script.txt

C:\WINDOWS\system32\ftp.exe -s:D:\Backup\script.txt
del D:\Backup\script.txt
exit

This script connect to ftp.mysite.com (just change the address to any other FTP server you want), sends login and password, changes (with “lcd”) the local work path to D:\Backup and┬ádisables the prompt to void confirmations;

then it downloads (mget) a file with a variable name, for example 060725050315.psc (this is the daily backup I would like to download). My additional problem was that I knew the first part of the file name (060725… it’s today date!) and its extension (.psc), but not the hour (in the example, 050315), because it indicates the hour when the remote backup ended. So I used a little Windows batch script that extracts current year, month and day (DATE:~8,2, DATE:~3,2 and DATE:~0,2) from my system’s local time (it’s in italian format, DD/MM/YYYY),┬áthen a “*” wildcard character and the fixed extension.
So I’m sure to download the today backup(s), regardless of the hour…

at the end, it disconnects (“bye”).

Because of the variable date problem (see above), the whole script first writes updated FTP commands in a temporary file (D:\Backup\script.txt), then it call ftp.exe with the new .txt file as argument. Finally, it delete the text file.

The last step I did was to add my .bat file to the Windows’ scheduled tasks, to make it run daily, at 5.15 AM ­čśë

This entry was posted in Tricks. Bookmark the permalink. Trackbacks are closed, but you can post a comment.

6 Comments