Sponsored Content
Full Discussion: Please help with .sh script
Special Forums Windows & DOS: Issues & Discussions Please help with .sh script Post 302573211 by coldwish on Sunday 13th of November 2011 02:56:13 PM
Old 11-13-2011
Please help with .sh script

Hello experts... I have a unix .sh script and i need to convert it to a .bat script. I am a newbie and i came here for you`re help. so here we go:

Code:
#!/bin/sh

prefix=C:/GnuWin32
exec_prefix=${prefix}
datadir=${prefix}/share
tmpdir=${TMPDIR:-/tmp}

# argument checking
if [ ${#} -ne "2" ]; then
	echo "Usage: ${0} <word document> <text output file>"
	exit 1
fi

USE_DUMP=0
which elinks >/dev/null 2>&1
if [ ${?} -eq "0" ]; then
    USE_DUMP=3
else
    which links >/dev/null 2>&1
    if [ ${?} -eq "0" ]; then
	USE_DUMP=2
    else
	which lynx >/dev/null 2>&1
	if [ ${?} -eq "0" ]; then
	    USE_DUMP=1
	fi
    fi    
fi

if [ $USE_DUMP -eq "1" ]; then
	echo "Could not find required program 'elinks' or 'links'"
	echo "Using lynx. Ouput will be pretty ugly."
elif [ $USE_DUMP -eq "0" ]; then
	echo "Could not find required program 'elinks', 'links', or even 'lynx'"
	echo "Using wvWare -x wvText.xml. Ouput will be pretty bad."
fi

if [ $USE_DUMP -gt "0" ]; then

    # first, test for wvHtml
    which wvHtml >/dev/null 2>&1
    if [ ${?} -ne "0" ]; then
       	echo "Could not find required program 'wvHtml'"
	exit 1
    fi

    # intermediate file
    TMP_FILE=`mktemp "$tmpdir/wv-XXXXXX"`
    TMP_FILE=`basename "$TMP_FILE"`

    wvHtml -1 "${1}" --targetdir="${tmpdir}" "${TMP_FILE}" >/dev/null 2>&1
    if [ ${?} -ne "0" ]; then
	echo "Could not convert into HTML"
	exit 1
    fi

    if [ $USE_DUMP -eq "3" ]; then
	# elinks does the best
	elinks -dump -force-html "${tmpdir}/${TMP_FILE}" > "${2}"
    elif [ $USE_DUMP -eq "2" ]; then
	# links does a pretty good job
	links -dump "${tmpdir}/${TMP_FILE}" > "${2}"
    else
	# lynx sucks, but does better than wvText.xml
	TERM=vt100 lynx -dump -force_html "${tmpdir}/${TMP_FILE}" > "${2}"
    fi;

    if [ ${?} -ne "0" ]; then
	    echo "Could not convert into Text"
	    rm -f "${tmpdir}/${TMP_FILE}"
	    exit 1
    fi

    # clean up
    rm -f "${tmpdir}/${TMP_FILE}"

else
    # fall back onto our cruddy output
    # this is, admittedly, better than running
    # 'strings' on the word document though :)
    wvWare -x ${datadir}/wv/wvText.xml "${1}" > "${2}"
fi

this script is part of gnuwin32 conversion tool and should it convert .doc files in .txt files. Please help me!
 

5 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

create a shell script that calls another script and and an awk script

Hi guys I have a shell script that executes sql statemets and sends the output to a file.the script takes in parameters executes sql and sends the result to an output file. #!/bin/sh echo " $2 $3 $4 $5 $6 $7 isql -w400 -U$2 -S$5 -P$3 << xxx use $4 go print"**Changes to the table... (0 Replies)
Discussion started by: magikminox
0 Replies

2. Shell Programming and Scripting

Script will keep checking running status of another script and also restart called script at night

I am using blow script :-- #!/bin/bash FIND=$(ps -elf | grep "snmp_trap.sh" | grep -v grep) #check snmp_trap.sh is running or not if then # echo "process found" exit 0; else echo "process not found" exec /home/Ketan_r /snmp_trap.sh 2>&1 & disown -h ... (1 Reply)
Discussion started by: ketanraut
1 Replies

3. UNIX for Dummies Questions & Answers

Calling a script from master script to get value from called script

I am trying to call a script(callingscript.sh) from a master script(masterscript.sh) to get string type value from calling script to master script. I have used scripts mentioned below. #masterscript.sh ./callingscript.sh echo $fileExist #callingscript.sh echo "The script is called"... (2 Replies)
Discussion started by: Raj Roy
2 Replies

4. Shell Programming and Scripting

Shell script works fine as a standalone script but not as part of a bigger script

Hello all, I am facing a weird issue while executing a code below - #!/bin/bash cd /wload/baot/home/baotasa0/sandboxes_finance/ext_ukba_bde/pset sh UKBA_publish.sh UKBA 28082015 3 if then echo "Param file conversion for all the areas are completed, please check in your home directory"... (2 Replies)
Discussion started by: ektubbe
2 Replies

5. Shell Programming and Scripting

How to block first bash script until second bash script script launches web server/site?

I'm new to utilities like socat and netcat and I'm not clear if they will do what I need. I have a "compileDeployStartWebServer.sh" script and a "StartBrowser.sh" script that are started by emacs/elisp at the same time in two different processes. I'm using Cygwin bash on Windows 10. My... (3 Replies)
Discussion started by: siegfried
3 Replies
wvText(1)						      General Commands Manual							 wvText(1)

NAME
wvHtml - convert msword documents to text SYNOPSIS
wvText in_word_doc out_text_doc DESCRIPTION
wvText converts word documents into plain text, with formatting strikingly similar to the original document. MORE INFORMATION
http://wvware.sourceforge.net SEE ALSO
wvAbw(1), wvWare(1), wvHtml(1), wvLatex(1), wvCleanLatex(1), wvPS(1), wvDVI(1), wvPDF(1), wvRTF(1), wvWml(1), wvMime(1), catdoc(1), word2x(1) AUTHOR
Dom Lachowicz (current author and maintainer) WEB: http://wvware.sourceforge.net MAIL: cinamod@hotmail.com wvText(1)
All times are GMT -4. The time now is 06:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy