Code Sample |
#!/bin/lua -- (c) 2007 Robert Shingledecker -- Lua script to support printing via dfm printing icon. function checkPrintcap() printcap,err = io.popen("ls -s /opt/printcap|awk '{print $1}'") printcapSize = printcap:read("*l") printcap:close() return printcapSize end if checkPrintcap() == "0" then response = fltk.fl_choice("No printer found!\nSetup Printer Now?","No","Yes",NULL) if response == 1 then os.execute('aterm -T "apsfilter" -e sudo /usr/share/apsfilter/SETUP') if checkPrintcap() == "0" then os.exit(1) else os.execute('touch /tmp/printer.flag') end else os.exit(1) end end lprTest = io.popen("ps | grep lpd | grep -v 'grep lpd'") lprCheck = lprTest:read("*l") lprTest:close() if lprCheck == nil then print("Starting lpd...") os.execute("sudo /usr/sbin/lpd") end if #arg == 1 then os.execute("lpr -h -Plp "..arg[1]) end |