Cygwin -Windows Failed to initialize PRN device

I run shell scripts on the Windows command line, creating bash as the default application to open .sh files. I can run any script without input parameters, but for these scripts with input parameters I get the error message “PRN device failed to initialize”. I see that the parameters are not being passed to the script. How to pass argument to script shell from windows command line?

This is what I do on the command line.

  X:> OracleSPExec.sh Procedure Database
 PROCEDURE =
 export PROCEDURE
 DATABASE =
 export DATABASE
+4
source share
3 answers

it seems that the shell script uses the print command / builtin command, which may conflict with windows print.exe , which prints the file to PRN : device.

+8
source

Two possible problems:

  • Missing shebang #!

You should add this line at the beginning of your script:

  #!/usr/bin/bash 
  1. Unicode specification at the beginning of a file

Someday, if a file is written in UTF-8 using the specification, shebang cannot be interpreted. Remove the title (hidden?) Of the characters in front of your shebang.

+1
source

I ran into this problem trying to run some locally developed tag scripts that worked before, but I have a new laptop and it works under Windows 10. bash in the cygwin version that I installed, t seems to have print as a built-in command ( it has printenv and printf as external commands), and there is no print command other than a System32 command:

 $ type print print is hashed (/cygdrive/c/WINDOWS/system32/print) $ type echo echo is a shell builtin 

As a job, I added this line at the top of each script:

 alias print=echo 

And this fixed the problem “Failed to initialize PRN device”. It would be nice to know why this worked at some point.

+1
source

All Articles