Posts Tagged ‘DOS’

A sort of diff implementation in the MS-DOS world

Thursday, July 7th, 2011

The MS-DOS FC.EXE programs is useful to compare two files. Differences between files are shown introduced by the string “*****” otherwise, if the files are equal, no asterisks will are displayed.
Redirecting the output on a temporary file, using SET /P it’s possible to define a variable in order to handle both the cases (the files are different or the files are equals).

A sort of *nix diff implementation made by a batch script may be the following:

@echo off
fc %1 %2|find /c “*****” > tempfile.out
SET /P TestVar=<tempfile.out
del tempfile.out
echo TestVar=%TestVar%
if %TestVar% == 0 GOTO:FEQUALS
echo %1 and %2 are different
GOTO:EOF
:FEQUALS
echo %1 and %2 are equals

Off corse if You need something better of this silly diff version, You may find useful djcpp, cygwin or other unix-like platforms

batch ftp script

Sunday, February 7th, 2010

If for some reason You need a quick and dirty script to retrieve some file from a ftp server, just open your text editor and write some things into your file. Then a simple command line command will download the file You have just write the path.

MS-DOS way:

C:\TMP> TYPE COMMANDFILE.TXT

username

password

dir

get wp-config.php

quit

C:\TMP> FTP -S:COMMANDFILE.TXT ftp.server.name

UNIX/LINUX way:

$ cat test

user username password

dir

get wp-config.php

quit

$ ftp -n ftp.server.name < test