Skip to content

dlqs/SOCprint

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NAME
  socprint.sh - POSIX™-compliant, zero-dependency shell script to print in NUS SoC

SYPNOSIS
  socprint.sh (p|print) [options] <username> <printqueue> [-|<filepath>]
  socprint.sh (j|jobs ) [options] <username> <printqueue>
  socprint.sh (l|list ) [options] <username>
  socprint.sh (h|help )

QUICKSTART
  To print a file instantly, copy and paste the following line into your shell:
  curl -s https://raw.githubusercontent.com/dlqs/SOCprint/master/socprint.sh | sh -s -- print <username> <printqueue> <filepath>

  Alternatively, use the hosted version at https://socprint.xyz

DESCRIPTION
  This script requires a POSIX™-compliant sh, a sunfire account, and connection to
  SoC wifi.

  Besides the above, this script has zero-dependencies, is portable, and handles text/byte streams. This makes printing
  in SoC a painless, non-ass-sucking experience that doesn't require installing any drivers.

COMMANDS (shortname|longname)
  (p|print) Print a file at specified printqueue.
  (j|jobs ) List jobs at specified printqueue.
  (l|list ) List all printqueues.
  (h|help ) Show this message.

OPTIONS
  <username>
    Sunfire username, without the @sunfire.comp.nus.edu.sg part.

  <printqueue>
    Printer + suffix. See PRINTQUEUES for commonly-used printers.

  [-|<filepath>]
    Print file. Recommended PDF/text. Undefined behaviour for other file types.
    If unspecified or -, read from standard input.

  -i, --identity-file <filepath>
    (optional) Additional identity file to use with ssh. Skip if you already set
    up sunfire identity files for ssh.

  -2
    (optional) Prints every two logical pages onto one physical page.
    Can only be used for pdf files that have portrait orientation.

  --dry-run
    (for debugging/tests) Echoes commands to be executed without executing them.

EXAMPLES
  To print from filepath:
    ./socprint.sh print d-lee psc008-dx ~/d/cs3210_tutorial8.pdf

  To combine with curl and the pipe operator:
    curl -s https://www.comp.nus.edu.sg/~ooibc/bxtree.pdf | ./socprint.sh print d-lee psc008-dx

  To print with shortname, using the redirection operator:
    ./socprint.sh p d-lee psc008-dx < ~/d/cs3210_tutorial8.pdf

  To check jobs:
    ./socprint.sh jobs d-lee psc008-dx

  To list printqueues:
    ./socprint.sh list d-lee

  To download and run from any directory:
    sudo curl https://raw.githubusercontent.com/dlqs/SOCprint/master/socprint.sh -o /usr/local/bin/socprint.sh
    sudo chmod 755 /usr/local/bin/socprint.sh

PRINTQUEUES
  Popular places:
  - COM1 basement:                   psc008-dx psc008-sx psc011-dx psc011-sx
  - COM1 L1, in front of tech svsc:  psts-dx psts-sx pstb-dx pstb-sx pstc-dx pstc-sx
  - -dx: double sided, -sx: single sided, -nb: no banner
  - Most other printers have user restrictions.
    See https://dochub.comp.nus.edu.sg/cf/guides/printing/print-queues.
  - For the full list of printqueues, generate with the -l option, or view the SOURCE.

IMPLEMENTATION
  Roughly speaking, the print command will:
  1. Login to sunfire using ssh.
     You will be prompted for your password, unless your identity files are set up.
     This script *does not* save/record your password.
  2. Copy the file into your home directory in sunfire, to a temporary file.
  3. Submit your job to the printqueue.
  4. List the printqueue. You job *should* appear. If not, something has gone wrong.
  5. Remove the temporary file.

STANDARDS
  This script targets conformance to POSIX.1-2017 standards (https://pubs.opengroup.org/onlinepubs/9699919799/).
  Yes, you read that right and no, we're not kidding. POSIX™ compliance is serious enterprise business!!!1
  POSIX™ is a Trademark of The IEEE.

SOURCE
  https://github.com/dlqs/SOCprint
  File bugs or POSIX™ compliance issues above.

CONTRIBUTORS
  Donald Lee, Julius Nugroho, Sean Ng

KEYWORDS
  how to print NUS SoC National University of Singapore School of Computing
  printers shell command line basement sunfire mac windows linux bsd ben

LICENSE
  This project is licensed under terms of the MIT License. Full text in source code.

GENERATE README
  ./socprint.sh help > README   && echo "List of valid printqueues, generated with list command on 5 March 2021\n" >> README   && ./socprint.sh list d-lee >> README

List of valid printqueues, generated with list command on 5 March 2021

psts
psts-sx
psts-dx
psts-nb
pstsb
pstsb-sx
pstsb-dx
pstsb-nb
pstsc
pstsc-sx
pstsc-dx
pstsc-nb
psgob
psgob-sx
psgob-dx
psgoc
psgoc-sx
psgoc-dx
psa206
psa206-sx
psa206-dx
psa403
psa403-sx
psa403-dx
psa411
psa411-sx
psa411-dx
psa413
psa413-sx
psa413-dx
psa421
psa421-sx
psa421-dx
psa425
psa425-sx
psa425-dx
psa426
psa426-sx
psa426-dx
psa427
psa427-sx
psa427-dx
psa501
psa501-sx
psa501-dx
psa502
psa502-sx
psa502-dx
psa518
psa518-sx
psa518-dx
psa518-nb
psa518-nb-sx
psa521
psa521-sx
psa521-dx
psa522
psa522-sx
psa522-dx
psa525
psa525-sx
psa525-dx
psa618
psa618-sx
psa618-dx
psc008
psc008-sx
psc008-dx
psc008-nb
psc011
psc011-sx
psc011-dx
psc011-nb
psc102
psc102-sx
psc102-dx
psc102-nb
psc102-nb-sx
psc106
psc106-sx
psc106-dx
psc106-nb
psc106-nb-sx
psc106-nb-dx
psc107
psc107-sx
psc107-dx
psc108
psc108-sx
psc108-dx
psc109
psc109-sx
psc109-dx
psc110
psc110-sx
psc110-dx
psc111
psc111-sx
psc111-dx
psc113
psc113-sx
psc113-dx
psc115
psc115-sx
psc115-dx
psc116
psc116-sx
psc116-dx
psc119
psc119-sx
psc119-dx
psc121
psc121-sx
psc121-dx
psc313
psc313-sx
psc313-dx
psc313-nb
psc313-nb-sx
psd001
psd001-sx
psd001-dx
psd002
psd002-sx
psd002-dx
psd003
psd003-sx
psd003-dx
psd102
psd102-sx
psd102-dx
psd103
psd103-sx
psd103-dx
psd105
psd105-sx
psd105-dx
psd106
psd106-sx
psd106-dx
psd107
psd107-sx
psd107-dx
psd109
psd109-sx
psd109-dx
psd110
psd110-sx
psd110-dx
psd238
psd238-sx
psd238-dx
psd238-nb
psd238-nb-sx
psd263
psd263-sx
psd263-dx
psd263-nb
psd263-nb-sx
psd313
psd313-sx
psd313-dx
psd313-nb
psd313-nb-sx
psd404
psd404-sx
psd404-dx
psd405
psd405-sx
psd405-dx
psd405-nb
psd405-nb-sx
psi505
psi505-sx
psi505-dx
psu102
psu102-sx
psu102-dx
psx302
psx302-sx
psx302-dx
psx302-nb
psx302-nb-sx
psx306
psx306-sx
psx306-dx
psx342a
psx342a-sx
psx342a-dx
psx342b
psx342b-sx
psx342b-dx

About

POSIX™-compliant, zero-dependency shell script to print in NUS SoC

Topics

Resources

License

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •