![]() |
nPrint - simple printing solution for N8X0'rs!
- an inquisitive soul recently posited a question
regarding printing for the IT... there are a few solutions, including a video showing someone printing via CUPS directly off the IT, printing via PB's KDE port, and (i thought) one approach possibly using FTP... - but my simple solution uses a software package readily available for the IT... dunno why i didn't think about this earlier... it's nothing special, really... the catch is that you need a *nix box already configured for printing and an available user account on the box (i use a notebook running Ubuntu)... - the incantation uses a shell command line pipe and ssh, with lpr on the receiving end... i tested .txt, .gif, .pdf, .jpg and all worked well (CUPS configuration)... #!/bin/sh # nPrint - print file from command line using remote host/acct # cat $1 | ssh $2 '( lpr )' - for example: nPrint foo.jpeg willie@192.168.1.101 or nPrint foo.txt varnell@foobar.net - note you can 'hardwire' the user/host if you like by substituting the $2 with username and IP/hostname... if you have not set up ssh key exchange, you'll be prompted for the remote user's password... (or you can just create a 'print' user on the remote system) - now if someone would come up with a gui file chooser, we'd have printing of files off the IT's desktop menu! :-) - hope this helps someone print from the IT... p.s. and i'm very sorry 770 users; this will work for you too... i'm abashed at how i callously forgot our vanguard IT owners... |
Re: nPrint - simple printing solution for N8X0'rs!
you are a genius.
Ah, and the guy printing from the tablet on youtube - it's me. |
Re: nPrint - simple printing solution for N8X0'rs!
Hehe, that's how I used to print from my N800 before I made the lprng package (which is just a few kilobytes anyway). :)
|
Re: nPrint - simple printing solution for N8X0'rs!
Quote:
(i really don't want to screw around with the file system on my IT, though) |
Re: nPrint - simple printing solution for N8X0'rs!
Searched but couldn't find... do you know where I can find this printing package? I would be printing to either a shared printer or a networked printer. TIA
|
Re: nPrint - simple printing solution for N8X0'rs!
Quote:
- the lprng build shouldn't be too hard - but it's the distribution of the package files across the file system, addition of the daemon to the memory pool, and the configuration that i don't want to conduct on my IT... (not that i'm not capable, mind you, but still messy if not officially supported)... - so for now i'll just use ssh and lpr on a remote system... simple and easy... - i will be looking into a small Python app to do file choosing... this will make things a bit more convenient with the stylus... |
Re: nPrint - simple printing solution for N8X0'rs!
Quote:
http://www.internettablettalk.com/fo...ad.php?t=10891 The link to the download is http://www.box.net/shared/zaj5id7dau The installed size is a bit larger than I remembered (the really small one was rdate), it's about 3.4MB. NB: Only tested on OS2007. |
Re: nPrint - simple printing solution for N8X0'rs!
Quote:
|
Re: nPrint - simple printing solution for N8X0'rs!
- i know it's bad form to post a reply to one's own post, but as an update on this feeble-minded printing solution:
i added an ash 'read' statement to the original script, and hardwired in a user- and hostname: #!/bin/sh # printit.sh - simple print for 770, n8x0 echo "File to print:" read file cat $file | ssh a_user@remote_box '( lpr )' exit 0 - the desktop entry: [Desktop Entry] Encoding=UTF-8 Version=0.1 Type=Application Name=printit Exec=/home/user/apps/printer.sh Icon=qgn_list_gene_default_app - and an osso-xterm one-liner (which gets around a convoluted '-e' osso-xterm option command line) named printer.sh and stored under /home/user/apps: #!/bin/sh /usr/bin/osso-xterm -e /home/user/apps/printit.sh - selecting the printit menu item opens an osso-xterm window which prompts for a filename (type full pathname to the file, such /home/user/MyDocs/foo.pdf or /media/mmc1/mypics/foo.gif), and then waits for an ssh password prompt on the remote box (OS X, *BSD, or Linux) hosting the *nix print server and lpr command... - i guess one could put in an 'ls' command for a specific directory before prompting for the filename as a reminder - perhaps: ls /home/user/print_folder/ - anyhow, now i have printing off the task menu! - hope this helps someone! |
Re: nPrint - simple printing solution for N8X0'rs!
I really like this lightweight approach, since I'm running standard maemo os2008 (not debian, not booting off mmc). I set up cups on my little nslu2 NAS (backup server mainly, "unslung").
Is there some kind of standardized file selection gui we could easily build off of? It would also be cool to add capability for a few more print options. These would be simple to add to your xterm-based script, though. Mostly file selection is a pain. Maybe calling from an existing file browser would be easiest. BTW, here's a bookmarklet to convert the current web page to pdf for printing with lpr (still takes an extra couple of clicks to save the pdf): javascript:void(location.href='http://www.htm2pdf.co.uk/?url='+escape(location.href)) |
Re: nPrint - simple printing solution for N8X0'rs!
Would it be possible to have a "standard" package to install a printer as it is done in ACER Aspire One? With my Wife's Acer it was very easy to install our Network printer. Acer OS is debian based. To add a printer in this system is similar to the way we do in windows.
|
Re: nPrint - simple printing solution for N8X0'rs!
I'll post a first prototype of a gui for nprint later :)
|
Re: nPrint - simple printing solution for N8X0'rs!
By the way, comments, votes and links are welcome at
Network printing support https://bugs.maemo.org/show_bug.cgi?id=3099 I couldn't find any previous discussion about use cases. It would be good to know why people want to get printing support and what do they actually print from their devices. |
Re: nPrint - simple printing solution for N8X0'rs!
May also want to throw in some compression in there...
cat $1 | ssh -C $2 '( lpr )' Using -C will compress the stream in transit over SSH, it adds some more CPU use on the ITT during the time it sends, but it's likely to shorten the span of time dramatically for printing, since most printing jobs are ASCII heavy and aren't already compressed. |
Re: nPrint - simple printing solution for N8X0'rs!
2 Attachment(s)
Here's a first attempt.
Rename to nprint.py and run with: python nprint.py or python nprint.py filename I have no remote system to test this and so I need your feedback. Todo: - enable save button - checkbutton for compression - statusbar applet with drag&drop |
Re: nPrint - simple printing solution for N8X0'rs!
Oh, passwords don't work now so you have to copy your rsa key ...
|
Re: nPrint - simple printing solution for N8X0'rs!
Quote:
|
Re: nPrint - simple printing solution for N8X0'rs!
Quote:
|
Re: nPrint - simple printing solution for N8X0'rs!
Yes, it's a wrapper for ssh which intercepts the ask password prompt.
Example usage, "sshpass -p p!mp ssh qwerty12@thahustlerz.co.uk" The above uses sshpass which runs ssh (scp is supported too etc) to send the password p!mp to the ssh session which is connecting to the user qwerty12 at the thahustlerz site. But I need to fix the depends line to change it from ssh to openssh-client | ssh ... |
Re: nPrint - simple printing solution for N8X0'rs!
Quote:
However, this sets a really example, in that it uses a clear-text password. This is a terrible security practice, even on something like the tablet. There's an excellent solution to the "problem" of supplying a password to ssh connections, the ssh-agent program. This has several advantages: 1. it's already on the tablet (no additional software required) 2. it's thoroughly tested 3. it's a standard method, available on virtually any platform that has an ssh client 4. it doesn't store a clear-text password and no password is available in the environment strings or system memory (a more serious consideration on a multi-user machine) |
Re: nPrint - simple printing solution for N8X0'rs!
Quote:
|
Re: nPrint - simple printing solution for N8X0'rs!
Bongo -
Wow. This is really great. I didn't expect to go to sleep and wake up to 100 lines of free python code! I haven't tried it yet, but will later today (have to take my little one to gymnastics in a few minutes) Regarding the passwords, I think setting up ssh keys is fine. I worry a bit about going password-less (password-less key) to my server just because there's already no password to get into the "user" account on the Nokia. But I can have a special printing account on my print server without many access privileges, I think. If we don't mind making it lpr-specific, then it would be great to add a few options that apply to all printers, such as page-ranges. If the target audience is people who can set up a print server, then it may be safe to assume they can edit a few choice lines in the script file to make printer-specific options. I'm imagining a set of check-able options, where the user can edit a few lines in the script to put in the specific commands and label for each option (things like greyscale, draft mode, etc.). It may be okay to hard code the print server host, user account, etc. in the script as well in this case. This avoids the code complexity of saving/reading user defaults, etc. At least save that complexity until a time where we think there's a broader user base out there. I'm thinking it would be good to have a single, catch-all text entry box to specify any additional one-time options to send to lpr (options used so infrequently that the user doesn't want to add a check-box to the script). I don't currently know python (I mostly use C/C++/csh), but I can probably figure it out if need be. Thanks for this great script. |
Re: nPrint - simple printing solution for N8X0'rs!
Did my python script work for somebody? Is there demand to continue my work on it?
|
Re: nPrint - simple printing solution for N8X0'rs!
Quote:
Also, are you saying that "lpr" (which is some sort of Unix printing function?) provides a way to print a pdf from the Tablet? (For me, who hasn't figured out how to print from the Tablet, the bookmarklet is useful because it gives me a way to email myself a pdf of a webpage, which I would then print from a computer.) |
Re: nPrint - simple printing solution for N8X0'rs!
Quote:
I'd love for you to continue development if you want to (and if you don't, I will). Regardless, thanks for what you've done so far. Hope you don't mind a few thoughts based on my particular use case: 1) I've got a single cups print server running linux with a single printer on it. So I don't mind hard-coding those into some variables in the script. For people who don't want to edit a file, you could possibly continue along your current path (enter host, user, etc. in the gui and eventually support saving them as defaults). But I'm not sure if this part is the best use of your coding time. Leaving it out will also save more window space for per-job configuration options. Best of all worlds would have a seperate window for printer configuration versus job options. 2) I'd like to be able to specify page-ranges to lpr. 3) I'd like to be able to check off a few printer-specific option like fast draft mode and greyscale mode to save paper. If there were a few programmable "memory slots" for such options in the script, I wouldn't mind going into the script to assign the variables containing a label and a "-o" command to lpr for each slot. Similar to #1, you could allow people to enter this stuff in the gui, but I wouldn't rank that as first priority. 4) It might be nice to have an additional place to manually enter -o options for this job (not to be saved for future jobs). For me, the main use of printing would be pdfs and web pages. I gave a bookmarklet in a previous mail for converting web page to pdf. Unfortunately, it doesn't always work well. For example, it doesn't succeed on gmail messages. Another common case would be printing a map from google maps. |
Re: nPrint - simple printing solution for N8X0'rs!
Quote:
Does anyone know if there's such an easy way as what we are doing here to talk to a printer shared by a Windows box? That could be a common case for a lot of people. I assume we might have to communicate via samba instead of ssh. Would it make it any easier if the Windows box was running an ssh server? |
Re: nPrint - simple printing solution for N8X0'rs!
Quote:
|
Re: nPrint - simple printing solution for N8X0'rs!
Quote:
However, the Adobe example seems to be talking about a network printer rather than a local printer. I'm not sure if that matters, or if we can also refer to a local printer that way. |
Re: nPrint - simple printing solution for N8X0'rs!
To run commands over ssh, you could simply use pexpect to put passwords through https://garage.maemo.org/frs/?group_...elease_id=2021
AirX is the most horrid code on the planet, but pexpect is rather well done and practical... |
Re: nPrint - simple printing solution for N8X0'rs!
Quote:
Again, the only control over job options here is the printer defaults. In an ideal world, we might at least figure out if a file with unknown type is ASCII and print it as .txt. Ironically, a postscript file may require an associated program like ghostscript just to send it to the printer (maybe trying to print as .txt is a really bad idea, in this case) |
Re: nPrint - simple printing solution for N8X0'rs!
1 Attachment(s)
Quote:
One little annoyance is that two orthogonal options (fast draft, and grayscale) are not presented as orthogonal by the printer driver (.ppd file). This kind of gets in the way of my idea to let the user just specify some number of generic option slots with the associated commands (because I had to insert code logic to combine the two options). I guess it would work if we just exposed all 4 combinations of the two options to the user, even though it's uglier. Even then, without some kind of radio box logic, the user might specify conflicting options. Maybe this is price for being both simple and general (simple, general, and pretty -- choose two). |
Re: nPrint - simple printing solution for N8X0'rs!
If you are printing to a network printer or print server, you can maybe use netcat if you know the port number(most time 9100)
cat /media/mmc1/mytextfile.txt | netcat 192.168.1.1 9100 Works on my printer for plain text files and several graphic formats. |
Re: nPrint - simple printing solution for N8X0'rs!
Quote:
|
Re: nPrint - simple printing solution for N8X0'rs!
Quote:
edit: oh i see there is also html2text available so i will have toremember that for printing nots |
Re: nPrint - simple printing solution for N8X0'rs!
Quote:
|
Re: nPrint - simple printing solution for N8X0'rs!
This is a cool project.
I'd love a simple GUI frontend for sshfs, so I could mount remote drives on my tablet without having to use the command line. Quote:
|
Re: nPrint - simple printing solution for N8X0'rs!
Quote:
I am too dumb to find it at http://repository.maemo.org Thanks in advance. Edit: I mean netcat for N900. |
All times are GMT. The time now is 01:11. |
vBulletin® Version 3.8.8