![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| character set conversion in unix C | gucho | High Level Programming | 1 | 03-01-2008 05:27 AM |
| Dos to Unix conversion | john413 | Shell Programming and Scripting | 1 | 09-10-2005 12:13 PM |
| Unix to EBCDIC conversion | Bab00shka | UNIX for Dummies Questions & Answers | 2 | 01-20-2005 09:58 AM |
| unix to windows conversion | misc19432043 | Filesystems, Disks and Memory | 2 | 10-10-2002 11:08 PM |
| Time conversion in Unix | kamlakar | UNIX for Advanced & Expert Users | 1 | 04-22-2002 09:55 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
conversion from Unix to windows
Hey guys,
Im looking to convert the following script into batch language for windows / DOS but my knowledge of batch syntax is nill - but i have good knowledge of UNIX shell...can anyone help? #!/bin/sh if [ $# -lt 2 ] ; then echo "UNCERTAIN:" echo "Too few arguments" echo "Usage: file_exists <filename> <exists|notexists|contains> [<text_to_search>]" echo "!!SCRIPT_FINISHED!!" exit 1 fi if [ $2 == "exists" ] ; then if [ -f "$1" ] ; then echo "TRUE:" echo "$1 file exists" else echo "FALSE:" echo "$1 file does not exist" fi fi if [ $2 == "notexists" ] ; then if [ -f "$1" ] ; then echo "FALSE:" echo "$1 file exists" else echo "TRUE:" #!/bin/sh if [ $# -lt 2 ] ; then echo "UNCERTAIN:" echo "Too few arguments" echo "!!SCRIPT_FINISHED!!" exit 1 fi if [ $2 == "exists" ] ; then if [ -f "$1" ] ; then echo "TRUE:" echo "$1 file exists" else echo "FALSE:" echo "$1 file does not exist" fi fi if [ $2 == "notexists" ] ; then if [ -f "$1" ] ; then echo "FALSE:" echo "$1 file exists" else echo "TRUE:" echo "$1 file does not exist" fi fi if [ $2 == "contains" ] ; then if [ -f "$1" ] ; then TIME=`date|tail -c19|head -c5` FOUND=`cat $1|grep $TIME|grep $3` if [[ -n $FOUND ]] ; then echo "TRUE:" echo "File $1 contains [$3]" else echo "FALSE:" echo "File $1 does not contain [$3]" fi else echo "FALSE:" echo "$1 file does not exist" fi fi echo "!!SCRIPT_FINISHED!!" Thanks josh |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
How about installing Cygwin (or Microsoft Services for Unix) on the Windows box.
|
|
#3
|
||||
|
||||
|
you can either go with cygwin/msu or you can look at some dos scripting books ... also check "help" and "if /?" on a windows cmd window for pointers on if tests and dos batch scripting ...
|
|
#4
|
|||
|
|||
|
I would chime in with the same response regarding CYGWIN. You can write some very functional DOS/NT scripts but even simple tasks are much tougher to implement. CYGWIN will give you an easier migration path.
If Cygwin can't be used, you start here. |
|||
| Google The UNIX and Linux Forums |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|