How to print program output?

You can redirect your program output to printer, so you will have it printed on printer instead of on screen. Use "|" as redirect operator:

Example:

program first print the sentence "hello,world":

$first

hello, world.

Now you use command first | lpr -P sel2058 can have "hello world." printed on printer sel2058.

$first | lpr -P sel2058