Skip to content
Advertisement

CUPS printing remote(http://) files from command line

I am trying to create a custom script to control my CANON SELPHY PRINTER form the command-line.

lp -d Canon_CP900 -o media="CP_C_size" /Users/sangyookim/Desktop/selphy.jpg

I have the tested the above code and it’s working perfectly as I intend it to.

But I have stumbled upon a problem.

When I replace the /Users/sangyookim/Desktop/selphy.jpg or filname to a web link such as the below, it will return me unable to access.. No such file or directory

http://res.cloudinary.com/splexz/image/upload/v1447239237/yer60xuvd6nmeldcbivd.png

How can I print images from the web using CUPS command line?

Advertisement

Answer

You cannot directly print a remote web page (because most Linux commands, lp included, do not know about URLs).

At least, you’ll need to first fetch that web page using a command line HTTP client like wget or curl, then use another command (with lp or lpr) to print it (and perhaps later remove that downloaded file from your local filesystem).

For images, you probably would need some converter before printing them, e.g. the convert command from ImageMagick (which happens to understand URLs, thanks to Mark Setchell for commenting on this), to convert them to some .pdf or perhaps .ps file (unless you have configured lp or CUPS to do the conversion automagically). Maybe you could use a2ps

You could write some script (or shell function) to do all the job.

In limited cases, you might also consider using some network file systems NFS, CIFS or set up some FUSE (I don’t recommend that).

Advertisement