HELP... Converting NT/DOS script to Unix

HELP... Converting NT/DOS script to Unix

Post by JJ » Wed, 04 Apr 2001 20:24:41



I have created a DOS/NT program to allow me to create, copy and
compare multiple files on multiple drives.  By using the NT shell
command START, I am able to open multiple windows and pass through
parameters to do this rather easily.  Unfortunately my ability to
convert this to unix is not very  good.  I can do simple shell scripts
but what I need to accomplish seems out of my ability so far, I am
asking for help here, please do what you can for me.  Thank you in
advance!

-------------------------

The mkfile program creates many different types of files which I then
copy to another directory and compare for differences.  

Basically this is what I need to do:

Create directories on 2 seperate disks:
        mkdir /volumes/disk1/source
        mkdir /volumes/disk2/dest
Copy program to source drive:        
        copy mkfile /volumes/source/disk1
Start infinate loop:                                  
        While x==0 (Stop on Exit code)
Execute mkfile program:          
       /volumes/disk1/source/mkfile all 10
Copy all files to another directory:
      copy /volumes/disk1/source*.* /volumes/disk2/dest
Binary file compare all files:                  
      cmp  -s /volumes/disk1/source/*.* /volumes/disk2/dest/*.*
Remove destination files                        
      RM /volumes/disk2/dest/*.*
Continue loop until error or manual stop
(Stop only on 1 or 2 Exit Code)  
      If x =1 || x=2 Exit

1) Is there an easy way to do this
2) How hard is it to convert my DOS/NT script
3) Can I open multiple terminal windows in Unix (OS X)?  (I am using
the Windows (Xwindows/Gnome/OS X) like environment)

I would like to have the program command line look something like
this:

multipat /volumes/disk1/ /volumes/disk2/

I have many different scripts that run together in DOS/NT that allow
me to create different size files for each window by calling a
different batch file to run.  I have included all of these files
below:

---------------------------------------------
MULTIPAT.BAT

REM Copies needed files from current directory to test drive
copy .\mkfile.exe %1:\
copy .\copypat.bat %1:\
copy .\makepat*.bat %1:\
copy .\startpat.bat %1:\

start /min /I startpat %1 0 2
start /min /I startpat %1 1 4
start /min /I startpat %1 2 3

---------------------------------------------

STARTPAT.BAT

REM MP %1 %2 %3  -- Works Correctly only on Windows NT
REM MP g 1 4
REM %1 = drive to test
REM %2 = initial source & destination directory number
REM %3 = call different makepat files 1- large 2- medium 3- small

REM This file copies all needed files to the root dir of tested drive
REM This will make one directory at a time and
REM copy the files from src %2 to dest %3

REM Make source directory
md %1:\src%2

REM log file
echo Multipat program on Drive %1 > %1:\logsrc%2.log
time /T >> %1:\logsrc%2.log
echo Running makepat %3 file >> %1:\logsrc%2.log
echo --------------------------- >> %1:\logsrc%2.log

REM Make files to use on test drive
%1:
CALL %1:\makepat%3.bat %1:\src%2

REM copy files from initial source to dest
CALL %1:\copypat.bat %1 src%2 dest%2

---------------------------------------------

MAKEPAT.BAT  (There are 4 different versions of this file)

REM This file makes 3.4 Gigs per source directory when run with
REM multipat.bat it creates 34 GB of data in the Source Directories
REM Then 34 GB in the Destination directories for roughly 70 GB of
data

cd %1
../mkfile all 1
../mkfile all 100
../mkfile all 95043
../mkfile all 50209
../mkfile all 40309
../mkfile all 12345
../mkfile all 8192
../mkfile all 16384
../mkfile all 44

---------------------------------------------

COPYPAT.BAT

REM  COPYPAT.BAT
REM  %1 = Drive to test
REM  %2 = source directory
REM  %3 = destination directory

REM Start Counter
 set count=0

:REPEAT
      REM increment counter by 1
       set /a count+=1

       REM Append date/time/counter to logfile
       date /T >> ..\log%2.log
       time /T >> ..\log%2.log
       echo File Compare has compared %2 to %3: %count% times >>
..\log%2.log
       echo ------------------------------------------------- >>
..\log%2.log

        REM delete specified files without prompting
        DEL %1:\%3\*.* /Q
        RD %1:\%3
        MD %1:\%3
        REM copy all files and display source & destination
        XCOPY/v/f %1:\%2\*.* %1:\%3\*.*

        REM do binary compare on all files
        FC %1:\%2\*.* %1:\%3\*.* /B
        IF ERRORLEVEL==0 GOTO REPEAT

 
 
 

HELP... Converting NT/DOS script to Unix

Post by Walter Brisco » Wed, 04 Apr 2001 21:22:35




Quote:>I have created a DOS/NT program to allow me to create, copy and
>compare multiple files on multiple drives.  By using the NT shell
>command START, I am able to open multiple windows and pass through
>parameters to do this rather easily.  Unfortunately my ability to
>convert this to unix is not very  good.  I can do simple shell scripts
>but what I need to accomplish seems out of my ability so far, I am
>asking for help here, please do what you can for me.  Thank you in
>advance!

What UNIX commands have you looked at?
diff -r may well answer the comparison part of your requirement.
I suspect all the rest is noise.
--
Walter Briscoe

 
 
 

HELP... Converting NT/DOS script to Unix

Post by Faux_Pseu » Thu, 05 Apr 2001 16:52:14


this seems like relitivly simple script.
if you go and get "Teach Your Self Shell Programing in 24 Hours"
by Sams

You have a good idea of how the code should flow
and have most of the single lines done already.

You could have this down in no time flat.

--(Once apon a time, in comp.unix.shell,)--
                --(JJ said it like only they can.)--

Quote:> I have created a DOS/NT program to allow me to create, copy and
> compare multiple files on multiple drives.  By using the NT shell
> command START, I am able to open multiple windows and pass through
> parameters to do this rather easily.  Unfortunately my ability to
> convert this to unix is not very  good.  I can do simple shell scripts
> but what I need to accomplish seems out of my ability so far, I am
> asking for help here, please do what you can for me.  Thank you in
> advance!

<code/explination snips>

--
--(UIN=66618055)--

GUI's are for slackers.  ibpconf.sh 6.1 on freshmeat.net  
The easiest way to customize the command line.  By Faux_Pseudo

 
 
 

1. Unix Script to convert text files to DOS format?

  I want to make a script that will let a person create or edit a text
file, saving it in DOS format.  

I am trying to get people to be data maintainers on our gopher;
the problem is that many of them accidently use UNIX to modify their text
files before ftp-ing them over to our gopher, losing the Carriage
Returns ( I am guilty of this myself ).  We want all our gopher files to
be in a DOS format so DOS gopher clients can read them.

Does anyone know of a script or know of the translations I have to do to
make a UNIX file into a DOS file?

PS. I envision a simple script called "edit" ( like in DOS ) that will
use pico and then translate characters.

Thanks in advance!
                                   ,        ,
   Chief weapons of UNIX:         /(        )`
    fear, surprise, and           \ \___   / |
    ruthless efficiency.          /- _  `-/  '
                                 (/\/ \ \   /\
                                 / /   | `    \   Peter Zuge
                                 O O   ) /    |   Gopher Administrator
                                 `-^--'`<     '   Information Technology
                     TM         (_.)  _  )   /    
  |  | |\  | ~|~ \ /             `.___/`    /     send e-mail to:

  `__| |  \| _|_ / \  <----.     __ / __   \
                      <----|====O)))==) \) /====
                      <----'    `--' `.__,' \
                                   |        |
                                    \       /
                               ______( (_  / \______
                             ,'  ,-----'   |        \
                             `--{__________)        \/

2. tmp/swap on 2.5 broken?

3. Converting unix shell scripts to dos batch files

4. Re-installing LILO on RedHat 4.1

5. convert trivial Dos bat script into bash script

6. newbie natd and ipfw startup question

7. Need Help: converting LF, CR for text file between UNIX and DOS

8. setuid on Directory has no Effect

9. Help - need to convert Unix class lib into DOS.

10. Looking for Unix pgm, converts text from unix to dos and back.

11. Need to convert DOS to UNIX with a *limited* set of UNIX commands

12. migration tool from UNIX script to NT script

13. help in learning how to do Bourne shell scripts then converting them to csh scripts