UNIX to DOS.

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
jocor826
Posts: 2
Joined: 16 Apr 2014 21:49

UNIX to DOS.

#1 Post by jocor826 » 16 Apr 2014 23:31

I've been assigned the task of converting our UNIX C shell scripts to DOS because I told them that it could be done and because we're moving to an all DOS/Windows environment from Solaris--what have I done? It just seems like you could so.... Here I am researching UNIX equivalents to DOS (e.g., GREP, SED, etc.). Through this group I've already some amazingly flexible code that I didn't think was possible using DOS batch files. That said...

My question is, can this be done? Is there anything like SED in DOS? I found that I could FIND instead of GREP to some extent.

Any tips or websites that might put me on my task's path would be appreciated. Thanks.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: UNIX to DOS.

#2 Post by foxidrive » 17 Apr 2014 01:35

`repl.bat` - download from: https://www.dropbox.com/s/qidqwztmetbvklt/repl.bat

`findrepl.bat` - download from: https://www.dropbox.com/s/rfdldmcb6vwi9xc/findrepl.bat


Repl.bat is sed-like
Findrepl.bat is grep-like

Both run using native Windows Jscript and are quick and robust - and will only require some adjustment to Windows regexp and the syntax.
Findrepl is by Aacini and Repl is by Dave Benham, and are both regulars here.

There are threads here for both tools also and the links are inside each of the batch files.

jocor826
Posts: 2
Joined: 16 Apr 2014 21:49

Re: UNIX to DOS.

#3 Post by jocor826 » 17 Apr 2014 02:36

thanks foxidrive for the prompt response.

I'm a little confused though and please understand that I'm not familiar with all that can be done at the DOS command line. But how is Javascript being supported without a browser?

Thanks.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: UNIX to DOS.

#4 Post by foxidrive » 17 Apr 2014 05:10

Jscript is part of Windows Scripting Host (WSH for short) and is a different beast to Javascript.

VB scripts and Jscript can both be implemented through cscript.exe/wscript.exe and run natively in Windows since W2K from memory.
There was an optional download for Win 9x to support WSH.

Windows has Powershell that can be scripted also.
It is quite good but has a disadvantage in that scripts will not run on a machine by default, until you manually change the permissions for executing scripts.

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: UNIX to DOS.

#5 Post by Squashman » 17 Apr 2014 06:26

Why not just use the Windows Ports of all those nice tools you had on your Unix boxes.
http://unxutils.sourceforge.net/
http://gnuwin32.sourceforge.net/

While I do agree with trying to do everything with Native code it may help you transition better to Windows.

npocmaka_
Posts: 516
Joined: 24 Jun 2013 17:10
Location: Bulgaria
Contact:

Re: UNIX to DOS.

#6 Post by npocmaka_ » 17 Apr 2014 12:42

Squashman wrote:Why not just use the Windows Ports of all those nice tools you had on your Unix boxes.


While I do agree with trying to do everything with Native code it may help you transition better to Windows.


BTW. there are Windows Services for UNIX from M$ -

http://www.microsoft.com/en-us/download ... spx?id=274 - v3.5 for XP,2003
http://www.microsoft.com/en-us/download ... px?id=2391 - for Vista,7,2008

And they come with a bunch of command line tools including posix.exe ,x server , shell and so on.
But the size is a little bit bigger..


But when it comes to install external tools I would prefer cygwin:

Code: Select all

http://www.cygwin.com/

goldfish
Posts: 10
Joined: 31 Mar 2014 07:02

Re: UNIX to DOS.

#7 Post by goldfish » 19 Apr 2014 23:23

jocor826 wrote:I've been assigned the task of converting our UNIX C shell scripts to DOS because I told them that it could be done and because we're moving to an all DOS/Windows environment from Solaris--what have I done? It just seems like you could so.... Here I am researching UNIX equivalents to DOS (e.g., GREP, SED, etc.). Through this group I've already some amazingly flexible code that I didn't think was possible using DOS batch files. That said...

My question is, can this be done? Is there anything like SED in DOS? I found that I could FIND instead of GREP to some extent.

Any tips or websites that might put me on my task's path would be appreciated. Thanks.

if you find that you often need to do this type of "conversion" from unix to Dos and from Dos to unix, my advice is to use a cross platform language. Perl Python Java etc does the job. You only need minor changes or no changes to port from one platform to another.

Post Reply