Author Topic: How to print to any printer from Classic Mac OS using macOS / X.  (Read 2062 times)

Offline Slimes

  • Newcomer
  • *
  • Posts: 3
  • New Member
    • Slimes
How to print to any printer from Classic Mac OS using macOS / X.

I. From the macOS Terminal:

   lpstat -p
   Make note of the printer you want to use.
   example: Brother_MFC_L2740DW_series
   
II. Open Script Editor on macOS / X. Input the following script:
________________________________________________________________________
on adding folder items to this_folder after receiving these_items
   try
      tell application "Finder"
         repeat with i from 1 to number of items in these_items
            try
               set this_item to item i of these_items
               set the path_string to this_item as string
               set the final_path to quoted form of POSIX path of path_string
               do shell script "/usr/bin/lp -d Brother_MFC_L2740DW_series " & final_path
               move this_item to trash with replacing
            on error error_message
               tell application "Finder"
                  display dialog "Error for item " & (this_item as string) ¬
                     & ": " & error_message buttons {"Continue", "Cancel"} ¬
                     default button 1 giving up after 120
               end tell
            end try
         end repeat
      end tell
   on error error_message
      tell application "Finder"
         display dialog error_message buttons {"Cancel"} ¬
            default button 1 giving up after 120
      end tell
   end try
end adding folder items to
________________________________________________________________________

III. Save the script from II. into your
~/Library/Scripts/Folder Action Scripts folder.
If that folder doesn't exist, create it.

IV. Create a folder to attach the script made in II.
Right/CTRL click the folder and select Services->Folder Action Setup...

V. Select the script from the drop menu made in II.

VI. Setup an FTP server on macOS / X. I recommend QuickFTP from the App
Store. It doesn't require an install. Its just a simple App.

VII. Install an FTP client on your Classic Mac.

VIII. Connect to your macOS / X FTP server and upload the file into the
folder created in IV. It will print in a few seconds.

http://www.slimes.ca
gopher://sdf.org/1/users/slimes/

Offline V.Yakob

  • Enthusiast Member
  • ***
  • Posts: 77
  • Mac User
Re: How to print to any printer from Classic Mac OS using macOS / X.
« Reply #1 on: August 10, 2023, 12:28:10 PM »
~/Library/Scripts/Folder Action Scripts folder.
If that folder doesn't exist, create it.

I've always thought it should be like this: ~/Library/Workflows/Applications/Folder Actions/

You may like my rough code better. :)

Code: [Select]
property FileExt : {"docx", "doc", "pages", "pdf"}

on adding folder items to this_folder after receiving added_items
repeat with AddedFiles in added_items
set Printer to do shell script "lpstat -p | awk '{print $2}'"
tell application "System Events"
if the name extension of the AddedFiles is in (FileExt as list) then ¬
set PrintingFile to (POSIX path of AddedFiles as text)
end tell
my StartPrint(Printer, PrintingFile)
end repeat
end adding folder items to

on StartPrint(Printer, PrintingFile)
set PushPrint to do shell script "/usr/bin/lp -d" & space & Printer & space & quoted form of PrintingFile
set JobID to do shell script "echo" & space & quoted form of PushPrint & space & "| /usr/bin/awk '{print $3}'"
my CheckPrint(JobID, PrintingFile)
end StartPrint

on CheckPrint(JobID, PrintingFile)
set Filename to name of (info for (PrintingFile))
repeat 5 times
if (do shell script "lpstat -R | awk '{print$2}'") is not in JobID then
display notification Filename with title "Printing from Mac OS 9" subtitle "successfully sent to print"
do shell script "rm -f" & space & quoted form of PrintingFile
exit repeat
end if
delay 1
end repeat
if (do shell script "lpstat -R | awk '{print$2}'") is in JobID then ¬
display dialog "File " & quoted form of Filename & " was not printed" with title ¬
"Printing from Mac OS 9" buttons {"OK"} default button 1 with icon stop giving up after 10
end CheckPrint
PPC — PM 8100/80, PM 9600/300, PM G3 Minitower (Rev. C), PM G3 B&W (Rev. B), PM G4 Quicksilver (2002), PM G4 MDD (2003), PM G5 (Late 2005).
Intel — Mac mini (mid 2010), iMac 5k (2017), Mac mini (2018).
AppleSilicon — Mac mini (2020), Mac Studio M2 Max + Apple Studio Display.