Hello, my name is John McPherson. I work as a contractor for the DOL, and I am trying convert some code I maintain in an application to send output files to a printer. Right now, the code( a bash script) just slowly prints the output file on the screen, and the customer wants to have it sent to the printer instead. I work on a 64-bit Oracle( Sun) system with Solaris 11 as the Operating System. I have tried the command

     lpr -h -l $showfl

in the bash script, but that just errors off without printing. I kept searching online with google search, and found the command

fmt -u -w 200 $showfl | lpr

but that also just errored off without printing. I finally found a Solaris man page on google that listed all of the system commands, and I could not find the lpr or fmt command on the man page. I have to think that Solaris allows the user to send files to the printer, and I am just missing something when I try to update the bash script. Note that in the width specification of my second attempt, I have a large number. That is actually correct, these output files do have a lot of columns, and I am trying force the printer to print the output as landscape, not portrait. I was using the -h and -l options to block printing a banner page, and have the printer just print the output as it was sent. If anybody can help me get these output files to print from Solaris 11, it would be greatly appreciated.

Thank you for the documentation link, rproffit. Not having the -P option is the big problem I am seeing. However, I also have the issue that each state will be printing these outputs at their own office, not the National office I work at. Therefore, I cannot put a specific printer name in the bash script, since multiple states use the same bash script for running their version of the application. I see from the Oracle documentation that I can specify a class of printers with the -P option, but I am not assured that every state uses the same class of printer. I am not sure of what I should actually be putting as the printer name with the -P option.

"I am not assured that every state uses the same class of printer."

That's what your IT has to solve with a consistant way to resolve what printer to send to. Think over how they print now. They must know the printer name so maybe this is something you ask for in your script. Or you stump for a standard across the system for a default printer in some environment variable for scripts to use when called. Note: https://docs.oracle.com/cd/E19683-01/806-7612/customize-8/index.html

I have discussed this issue with the Network people, and there is no way that the Federal government can require state governments to adopt a standard printer. The Benefit Financial Model( BFM) is run on a server at the National Office, and the state users log in from their state office with Putty to run the BFM. Also the BFM is inside the firewall at the National Office, so the BFM cannot find the printer at the individual state offices. I discussed this with the customer, and the customer agreed to my suggestion that instead of printing, the BFM will email the file to the state user. I have been working on converting the bash script to send email instead of printing, and I am having a problem with the case statement that does the seding of the email. the code that is giving a problem is:

## print or display
    if test $print_flag
    then
      if [ $run = FF ]
      then
        rm -f picktbls
        /bfm/devt/comexec/prtmnu $showfl ##select tables >temp.d
        act=`cat temp.d`
        if [ "$act" = QUIT ]
        then ##canceled
          bfm_sigon
        elif [ "$act" != ALL ]
        then
          showfl=picktbls
        fi
      fi
                case $OPT1 in
                  ARKANSAS)
                    mailx -s "BFM Output" $ARUSER1 < $showfl;;
                  CONNECTICUT)
                    mailx -s "BFM Output" $CTUSER1 < $showfl;;
                  DC2)
                    mailx -s "BFM Output" $DCUSER3 < $showfl;;
                  GEORGIA)
                    mailx -s "BFM Output" $GAUSER1 < $showfl;;
                  INDIANA)
                    mailx -s "BFM Output" $INUSER1 $INUSER2 < $showfl;;
                  KANSAS)
                    mailx -s "BFM Output" $KSUSER1 $KSUSER2 < $showfl;;
                  KENTUCKY)
                    mailx -s "BFM Output" $KYUSER < $showfl;;
                  LOUISIANA)
                    mailx -s "BFM Output" $LAUSER1 $LAUSER2 < $showfl;;
                  MAINE)
                    mailx -s "BFM Output" $MEUSER1 $MEUSER2 $MEUSER3 < $showfl;;
                  MARYLAND)
                    mailx -s "BFM Output" $MDUSER2 < $showfl;;
                  MINNESOTA)
                    mailx -s "BFM Output" $MNUSER1 < $showfl;;
                  NORTH CAROLINA)
                    mailx -s "BFM Output" $NCUSER7 < $showfl;;
                  SOUTH CAROLINA)
                    mailx -s "BFM Output" $SCUSER1 $SCUSER2 < $showfl;;
                  VERMONT)
                    mailx -s "BFM Output" $VTUSER1 $VTUSER3 < $showfl;;
                  WEST VIRGINIA)
                    mailx -s "BFM Output" $WVUSER1 < $showfl;;
                  WISCONSIN)
                    mailx -s "BFM Output" $WIUSER1 < $showfl;;
                  *)
                    ;;
                esac
    else ##display on screen

When I try to run a state's BFM with this code included in the bash script, the script will error off without any error messages. I bring up Putty, enter the state userid and password, and Putty immediately exits. When I comment out the case statement, the state's BFM runs fine. I have checked other case statements in this script that I know work, and they are written the same way this case statement is written. There are other mailx statements in this script that I know work, and they are written as I have these mailx statements. I have Googled the case statement in bash scripts, and the examples I have found match how I have written this case statement. I have tried putting quotes around the case in variable, and that didn't help. I have tried it without a dollar sign in front of the filename variable, and that didn't help. Any help with this issue is greatly appreciated.

By now you figured out that without asking what printer to print can't be avoided.

Since printing is no longer the issue, I will close this thread, and open a thread about the case statement problem.

I now see that I will not be able send to the printer from a Solaris bash script, and therefore I am closing this thread.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.