LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Help required for executing ksh script on windows using cygwin (https://www.linuxquestions.org/questions/linux-newbie-8/help-required-for-executing-ksh-script-on-windows-using-cygwin-4175551773/)

newuser85 08-26-2015 04:28 AM

Help required for executing ksh script on windows using cygwin
 
Hi All,

I am trying to execute ksh script on windows sever using Cygwin and getting the below error message,

Unable to initialize device PRN
Unable to initialize device PRN
Unable to initialize device PRN

Need you help to know whats the issue and how to solve it.

thanks in advance.



Hi,

Sorry for not including more details, actually I have been asked to modify an existing ksh script on SUNOS/AIX environment to work on windows environment using Cygwin.

*********************************************************


scriptname=ftpNTRS.ksh
tokenname=ftpNTRS
scriptExec=$(echo "\nRunning: $0 $*")
################################################################################
usage () {
print " Usage: Retrieve file from NTRS FTP server"
print " Syntax: ftpNTRS.ksh Productline InterfaceType "
print " Supported Interface Programs: CB185 CONFR"
scriptExit "1" "$scriptname"
}
################################################################################
#Configuration
################################################################################
#Read subroutine libraries into memory
LAWDIR="E:\xxx_Script\Scripts"
. $LAWDIR\ftp_subs.ksh
. $LAWDIR\subs.ksh
#. $LAWDIR/bin/ftp_subs.ksh
#. $LAWDIR/bin/subs.ksh

#Identify server O/S. Set path variables.
#OSname=$(/usr/bin/uname -s)
OSname="CYGWIN_NT-6.1"
case "$OSname"

in
CYGWIN_NT-6.1 ) kshPath1="/usr/bin"
kshPath2="/usr/xpg4/bin"
kshPath3="/usr/ucb"
kshPath4="/opt/cups/bin" #Path for LP command - alter if not CUPS.
kshPath5="/opt/aspx/bin"
envID=$($kshPath1/basename $LAWDIR)
# companyID=$($kshPath1/basename $LAWDIR| $kshPath1/cut -b1-4)
# printerID=$($kshPath1/basename $LAWDIR| $kshPath1/cut -b2-4)
;;

AIX ) kshPath1="/usr/bin"
kshPath2="/usr/bin"
kshPath3="/usr/bin"
kshPath4="/opt/cups/bin" #Path for LP command - alter if not CUPS.
kshPath5="/opt/aspx/bin"
envID=$($kshPath1/basename $($kshPath1/dirname $LAWDIR))
# companyID=$($kshPath1/basename $($kshPath1/dirname $LAWDIR)|$kshPath1/cut -b1-4)
# printerID=$($kshPath1/basename $($kshPath1/dirname $LAWDIR)|$kshPath1/cut -b2-4)
;;

* ) echo "ERROR: Unknown O/S name."
echo " Path for KSH programs can not be defined."
;;
esac

DATE=`/usr/bin/date +C%y%m%d`
TIME=`/usr/bin/date +%H%M%S`
logDATE=`/usr/bin/date +%m%d%y%H%M%S`

#redirector STDOUT to a log file
scriptLogDIR=$LAWDIR/tmp
if [ ! -d "scriptLogDIR" ]
then
mkdir -p "$scriptLogDIR"
fi

scriptLogName=$tokenname.$logDATE
scriptLog=${scriptLogDIR}/${scriptLogName}
exec 6>&1
exec 1> $scriptLog

**********************************************************

Cygwin version details as below.


uname -r
2.2.1(0.289/5/3)

*****@HOST-014 ~
$ uname -a
CYGWIN_NT-6.1 HOST-014 2.2.1(0.289/5/3) 2015-08-20 11:42 x86_64 Cygwin

*****@HOST-014 ~
$

********************************************

Error on the logfile

Unable to initialize device PRN
Unable to initialize device PRN
Unable to initialize device PRN
Unable to initialize device PRN
Unable to initialize device PRN
Unable to initialize device PRN
Unable to initialize device PRN
Unable to initialize device PRN
Unable to initialize device PRN
Unable to initialize device PRN
Unable to initialize device PRN
Unable to initialize device PRN
Unable to initialize device PRN

***********************************************

Please advice.

wpeckham 08-26-2015 05:01 AM

in the dark...
 
Blind? Without any idea of the script contents or even a description?
You must think we are not only wizards, but mind readers! ;-)

Could you, perhaps, give us a little to go on?
Have you tried other scripts, and can you post an example of one that throws this error?
What have you attempted so far, and what results obtained?
Is this CYGWIN install current?

wpeckham 08-28-2015 06:00 AM

how many scripts are involved?
 
Thank you for adding the script example.

Note that this script sources other scripts, and the detail throwing errors may be in the other scripts.
Do you have CUPS running under CYGWIN? This appears to depend heavily CUPS or something that looks like it.
Is CUPS well configured and working? Do you have a PRN printer defined?

Have you checked all of the paths? Paths on a Linux system, or under CYGWIN, are likley to differ from those under AIX, SOLARIS, or HP-UX. (Having tripped over those issues on all three!)

I much prefer running native Linux and stopped using CYGWIN some while back. When I was using it I found it very powerful. Porting things from Linux to CYGWIN was easy. Porting things from AIX to Linux more challenging. You are trying to go direct from AIX land to CYGWIN, and that is likely to take some very careful and painstaking desk checking and troubleshooting skills. This is not something to expect to finish quickly.

Sounds like fun!

justdaven 01-25-2017 02:44 PM

I had the same issue..
 
This is due to a difference in command interpreter. The print command works with Korn Shell, but Bash uses echo, instead of print. Once I changed the prints (which in Korn route to the default printer port) to echos, I stopped getting the error.


All times are GMT -5. The time now is 06:31 PM.