1

I have a bash file called 1.sh follows :

#!/bin/bash

lpr "this doc.pdf"

The properties are set to "allow executing file as a program".

when i open the terminal and type

lpr ./1.sh

it prints on the printer to paper.

when I double click on the file and choose either "Run" or "Run in terminal" it does not print. Anyone any ideas.

Thank you

Kes
  • 285
  • 2
  • 17
  • it's a new system build. It was working on the old system. Perhaps I have something missing ? – Kes Apr 08 '14 at 13:52

1 Answers1

1

The working directory of the process when you start it by double-clicking is probably different than when you are logged in at the terminal, so there is no "this doc.pdf" in the current directory. Use an absolute path name in the script:

#!/bin/bash
lpr /path/to/"this doc.pdf"
chepner
  • 497,756
  • 71
  • 530
  • 681
  • Thank you. Attempting from same directory and have made path absolute just for sureity. – Kes Apr 08 '14 at 14:43
  • have been able to print to lp (not lpr) with script so think it is a package dependencies issue. Anyone have a list of base packages that must be installed for bash --> lpr printing. Likely have to load old operating system to see what printing packages were on it. Thank you for all help. – Kes Apr 08 '14 at 16:41
  • If you can print with `lpr` from the command line, it's probably not a dependency issue. What is the full path to `lpr`? The script may be using a different `PATH` than your interactive shell, so you could also try hardcoding the path to `lpr` in your script, e.g., `/usr/bin/lpr /path/to/"this doc.pdf"` – chepner Apr 08 '14 at 16:44
  • I agree. What you say feels right. Before I read this I installed cups-bsd package (Berkley produced lpr I think) and it worked. I suppose that the package fixed the paths, though yes not dependency. THANK YOU ! – Kes Apr 08 '14 at 21:51