The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
character set conversion in unix C gucho High Level Programming 1 03-01-2008 08:27 AM
Dos to Unix conversion john413 Shell Programming and Scripting 1 09-10-2005 03:13 PM
Unix to EBCDIC conversion Bab00shka UNIX for Dummies Questions & Answers 2 01-20-2005 12:58 PM
unix to windows conversion misc19432043 Filesystems, Disks and Memory 2 10-11-2002 02:08 AM
Time conversion in Unix kamlakar UNIX for Advanced & Expert Users 1 04-22-2002 12:55 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-10-2005
kiwi_bloke kiwi_bloke is offline
Registered User
  
 

Join Date: Aug 2004
Posts: 4
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
  #2 (permalink)  
Old 10-10-2005
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
  
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,407
How about installing Cygwin (or Microsoft Services for Unix) on the Windows box.
  #3 (permalink)  
Old 10-10-2005
Just Ice's Avatar
Just Ice Just Ice is offline Forum Advisor  
Lights on, brain off.
  
 

Join Date: Mar 2005
Location: in front of my computer
Posts: 637
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 (permalink)  
Old 10-10-2005
tmarikle tmarikle is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2005
Posts: 683
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.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:41 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0