Mac OS 9 Lives
Mac OS 9 Discussion => Mac OS 9, Hacks & Upgrades => Topic started by: Slimes on July 28, 2023, 11:19:01 PM
-
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.
-
~/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. :)
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