1

File prindi.sh contains

/usr/bin/lpr –P SL-M3325ND <teade.pdf

its inovoking returns error

/usr/bin/lpr: Error - unable to access "–P" - No such file or directory

If this command in invoked directly from command line it works:

# /usr/bin/lpr -P SL-M3325ND <teade.pdf
# lpq
SL-M3325ND is ready
no entries

How to fix this so that it can printed from prindi.sh also ?

  • 4
    The problem is the wrong kind of - sign in your script. Replace it with a good old-fashioned hyphen, and lpr will stop seeing –P as a (missing) file to be printed, and recognise -P as a flag (do you see they're different lengths?). – MadHatter May 6 '16 at 15:48
  • I'm guessing from your response that that fixed it, so I've written it up as a full answer. Please either accept my answer or delete the question (up to you which!) so it doesn't float around forever. Thanks, and I'm glad you got things working. – MadHatter May 7 '16 at 6:47
4

The problem is the wrong kind of - sign in your script (do you see they're different lengths?).

Replace it with a good old-fashioned hyphen, and lpr will stop seeing –P as a (missing) file to be printed, and recognise -P as a flag. And whoever wrote that script should stop using word processors to write shell scripts, and use a proper text editor instead (there's a difference!).

  • Oh yes, the joys (and pains) of Unicode... . You can have similar types of fun with the different types of quotes. – sleske May 12 '16 at 7:02

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.