Please help with .sh script

 
Thread Tools Search this Thread
Special Forums Windows & DOS: Issues & Discussions Please help with .sh script
# 1  
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!
# 2  
Old 11-14-2011
Um.. .sh to .bat? No way. Approach this from trying to solve the problem the windows way.

Looks like all it's trying to do is convert a file found on the web to some kind of xml document.
# 3  
Old 11-14-2011
An .sh file is not a .bat file. The capabilities are totally different (namely, .bat has almost none) and the tools quite different as well. There's no "conversion", just rewriting from scratch.

The script looks suspect anyway. I see nothing in it to convert .doc to .txt.
# 4  
Old 11-14-2011
as i said: this script is part of gnuwin32 conversion tool and should it convert .doc files in .txt files... and i know that i cannot convert .sh to .bat and i asked here if someone helps me rewriting it cause i`m a newbie..... to see why i need it i will also post a link:

....sourceforge.net/projects/gnuwin32/forums/forum/74807/topic/1447151]SourceForge.net: GnuWin: Need to create a wvTEXT.exe

the project developer said that this script can easily be rewrited to .bat...and i ask for some help Smilie
# 5  
Old 11-14-2011
If that was the case then certainly he could have done so himself...

99% of the script is irrelevant to you since most of it is for dealing with lynx or links, things which don't understand .doc anyway, not to mention things you won't have under Windows.

I'd suggest trying wv itself except wv doesn't appear to have a Windows version available, in fact nothing but pure source code.
Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. 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

2. 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

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

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

5. 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
Login or Register to Ask a Question