Problem with printing via Folder action script ...
Moderators: Cat_7, Ronald P. Regensburg, ClockWise
-
- Mac Mechanic
- Posts: 172
- Joined: Thu Mar 17, 2011 1:46 am
Re: Problem with printing via Folder action script ...
If you mean to see the FAS enabled folder and it's content while I am working in my OS 9 app ... yes, I just tried that and the added file does not print, but if I drag & drop manually the file it does print.
Could it be a permission issue ?
Could it be a permission issue ?
-
- Mac Mechanic
- Posts: 172
- Joined: Thu Mar 17, 2011 1:46 am
Re: Problem with printing via Folder action script ...
Thanks for the clue ... but not much of help on my side.
- Ronald P. Regensburg
- Expert User
- Posts: 7835
- Joined: Thu Feb 09, 2006 10:24 pm
- Location: Amsterdam, Netherlands
Re: Problem with printing via Folder action script ...
Which script do you use as folder action script for printing?
-
- Mac Mechanic
- Posts: 172
- Joined: Thu Mar 17, 2011 1:46 am
Re: Problem with printing via Folder action script ...
Here is the script:
property myPrinter : "HP_Officejet_8500" -- Le nom exact de l'imprimante est obtenu en faisant «lpstat -p» dans terminal.
on adding folder items to thisFolder after receiving theseItems
-- For each file of this folder ...
repeat with i in theseItems
-- ... define the file path and ...
set theFilePath to quoted form of POSIX path of i
-- ... print the file on the chosen printer.
do shell script "usr/bin/lpr -P " & myPrinter & space & theFilePath
do shell script "/bin/sleep 10"
-- Thrash the printed file.
do shell script "/bin/rm " & theFilePath
end repeat
end adding folder items to
property myPrinter : "HP_Officejet_8500" -- Le nom exact de l'imprimante est obtenu en faisant «lpstat -p» dans terminal.
on adding folder items to thisFolder after receiving theseItems
-- For each file of this folder ...
repeat with i in theseItems
-- ... define the file path and ...
set theFilePath to quoted form of POSIX path of i
-- ... print the file on the chosen printer.
do shell script "usr/bin/lpr -P " & myPrinter & space & theFilePath
do shell script "/bin/sleep 10"
-- Thrash the printed file.
do shell script "/bin/rm " & theFilePath
end repeat
end adding folder items to
- Ronald P. Regensburg
- Expert User
- Posts: 7835
- Joined: Thu Feb 09, 2006 10:24 pm
- Location: Amsterdam, Netherlands
Re: Problem with printing via Folder action script ...
Nice compact script. This script and other scripts as well as an Automator workflow work fine here as folder action for printing from SheepShaver in Yosemite. *
My main issue is that the desktop printers do not remember the location inside "Unix" to save the file. That problem started in one of the previous OSX versions (Mavericks?).
Where is the folder that has the script attached located in the shared folder/Unix volume in your setup?
Edit:
* Older scripts that use the Printer Setup Utility do not work anymore in Mavericks or later. That application does not exist there anymore.
My main issue is that the desktop printers do not remember the location inside "Unix" to save the file. That problem started in one of the previous OSX versions (Mavericks?).
Where is the folder that has the script attached located in the shared folder/Unix volume in your setup?
Edit:
* Older scripts that use the Printer Setup Utility do not work anymore in Mavericks or later. That application does not exist there anymore.
Last edited by Ronald P. Regensburg on Sat Mar 07, 2015 10:54 am, edited 1 time in total.
Reason:
Reason:
-
- Mac Mechanic
- Posts: 172
- Joined: Thu Mar 17, 2011 1:46 am
Re: Problem with printing via Folder action script ...
Sometimes utilities/services/scripts/workflows are added or replaced and the impact they can have in other area ... like in OS 9 are realized only later.
While playing around and testing to find a clue to my problem, I just realized that my symbolic links didn't display as expected in OS 9. If I had more than one, they didn't show up in OS 9's Finder window or selection window. They were created using an Automator workflow, and I don't remember where I got it from. I just installed SymbolicLinker's service, that I used before and now they all show up in OS 9.
While this seems back to normal, the FAS «Printing» folder bridging OS 9 and OS X, still does not work as expected.
To answer your question, I tried a few locations for the FAS «Printing» folder. At first, I created it from another user and placed it inside the Shared account ... «Users/Shared/Printing» so the FAS would execute from another account than mine that had FAS memory overload. That folder was accessible with a symlink placed inside SheepShaver's shared folder («MyUserAccount/Documents/SheepShaver»). That solution worked until I tried to bring back the «Printing» folder in my account. Now I am unable to do that anymore ??? Actually the «Printing» folder is in SheepShaver's shared folder «MyUserAccount/Documents/SheepShaver/Printing»
My SheepShaver files and folders's location are :
• the SheepShaver app is in the «Applications» folder
• the required SheepShaver files (ROM, keys and volumes) are in my «Applications Support/SheepShaver» folder
• my SheepShaver's shared folder is «MyUserAccount/Documents/SheepShaver»
I tried to group all SheepShaver's files and folder in only one folder inside the «Applications» folder, and the peculiar behavior is the same.
Is this getting more confusing than helpful ? One thing is sure ... FAS and FAD generates memory overload problem and many are complaining about it. Since it works for you, it is possible that some utilities or ressources have also a conflicting role.
Hope this is clear enough. Thanks for helping.
Robert
While playing around and testing to find a clue to my problem, I just realized that my symbolic links didn't display as expected in OS 9. If I had more than one, they didn't show up in OS 9's Finder window or selection window. They were created using an Automator workflow, and I don't remember where I got it from. I just installed SymbolicLinker's service, that I used before and now they all show up in OS 9.
While this seems back to normal, the FAS «Printing» folder bridging OS 9 and OS X, still does not work as expected.
To answer your question, I tried a few locations for the FAS «Printing» folder. At first, I created it from another user and placed it inside the Shared account ... «Users/Shared/Printing» so the FAS would execute from another account than mine that had FAS memory overload. That folder was accessible with a symlink placed inside SheepShaver's shared folder («MyUserAccount/Documents/SheepShaver»). That solution worked until I tried to bring back the «Printing» folder in my account. Now I am unable to do that anymore ??? Actually the «Printing» folder is in SheepShaver's shared folder «MyUserAccount/Documents/SheepShaver/Printing»
My SheepShaver files and folders's location are :
• the SheepShaver app is in the «Applications» folder
• the required SheepShaver files (ROM, keys and volumes) are in my «Applications Support/SheepShaver» folder
• my SheepShaver's shared folder is «MyUserAccount/Documents/SheepShaver»
I tried to group all SheepShaver's files and folder in only one folder inside the «Applications» folder, and the peculiar behavior is the same.
Is this getting more confusing than helpful ? One thing is sure ... FAS and FAD generates memory overload problem and many are complaining about it. Since it works for you, it is possible that some utilities or ressources have also a conflicting role.
Hope this is clear enough. Thanks for helping.
Robert
- Ronald P. Regensburg
- Expert User
- Posts: 7835
- Joined: Thu Feb 09, 2006 10:24 pm
- Location: Amsterdam, Netherlands
Re: Problem with printing via Folder action script ...
It is a mystery. I do not see FAD memory issues. Maybe it depends on the number of times a folder action script is used?
My SheepShaver print setup is a bit more complicated because I have multiple SheepShaver and BasiliskII setups for testing purposes. But the "Print" folder is always at root level in the shared folder and the shared folder is always somewhere in my Home folder. Most of my own folder action scripts are installed in ~/Library/Scripts/Folder Action Scripts/ but scripts installed in /Library/Scripts/Folder Action Scripts/ also work, as do Automator workflows installed in ~/Library/Workflows/Applications/Folder Actions/
My SheepShaver print setup is a bit more complicated because I have multiple SheepShaver and BasiliskII setups for testing purposes. But the "Print" folder is always at root level in the shared folder and the shared folder is always somewhere in my Home folder. Most of my own folder action scripts are installed in ~/Library/Scripts/Folder Action Scripts/ but scripts installed in /Library/Scripts/Folder Action Scripts/ also work, as do Automator workflows installed in ~/Library/Workflows/Applications/Folder Actions/
-
- Mac Mechanic
- Posts: 172
- Joined: Thu Mar 17, 2011 1:46 am
Re: Problem with printing via Folder action script ...
I created a new user account and installed SheepShaver the same way I did in my personal account. The PDF files prints from the FAS folder as expected but, like you, SheepShaver forgets the «Printing» folder location. Everytime, I have to select the folder again and give a name to the PDF file I want to print. In my account though .. it does remember the «Printing» folder.
What seems to happens in my account, is that SheepShaver drops the file to print in the FAS folder but does not print. In the background, the FAD and the System events processes begin to increase in memory usage size until all memory is used. When this happens, the FAS setup is not possible. The window opens with the spinning ball .. until I force quit those processes. Then the memory frees up, the processes's memory usage stabilizes but the job never prints.
Actually, my workaround is to print those jobs manually from the Finder.
Since it is not behaving the same way in the 2 accounts, there must be a sort of conflict, but how to resolve that ? Would you have a clue to how pinpoint the conflicting activities/processes/utilities ???
What seems to happens in my account, is that SheepShaver drops the file to print in the FAS folder but does not print. In the background, the FAD and the System events processes begin to increase in memory usage size until all memory is used. When this happens, the FAS setup is not possible. The window opens with the spinning ball .. until I force quit those processes. Then the memory frees up, the processes's memory usage stabilizes but the job never prints.
Actually, my workaround is to print those jobs manually from the Finder.
Since it is not behaving the same way in the 2 accounts, there must be a sort of conflict, but how to resolve that ? Would you have a clue to how pinpoint the conflicting activities/processes/utilities ???
-
- Mac Mechanic
- Posts: 172
- Joined: Thu Mar 17, 2011 1:46 am
Re: Problem with printing via Folder action script ...
In my user account, I just tried to drop a file in the «Printing» folder by printing to a PDF file in OS X from the PDF print option... Contrary to SheepShaver, i does print ... but even then the FAD's memory usage begins to increase slowly and steadily. It never stops ... certainly until the memory will crash or until I force quit the process.
- Ronald P. Regensburg
- Expert User
- Posts: 7835
- Joined: Thu Feb 09, 2006 10:24 pm
- Location: Amsterdam, Netherlands
Re: Problem with printing via Folder action script ...
I rarely restart my Mac. Uptime is now almost 5 days. FAD memory usage is at this moment 13.5 MB. When folder action scripts are used it will go up a little (yesterday evening to 17.5 MB), but after some time it will always go down again to around 13.5 MB.
- Ronald P. Regensburg
- Expert User
- Posts: 7835
- Joined: Thu Feb 09, 2006 10:24 pm
- Location: Amsterdam, Netherlands
Re: Problem with printing via Folder action script ...
BTW: If you do not need to choose a specific printer for printing from SheepShaver, this simplified script will print to the default printer:
Code: Select all
on adding folder items to thisFolder after receiving theseItems
-- For each file of this folder ...
repeat with i in theseItems
-- ... define the file path and ...
set theFilePath to quoted form of POSIX path of i
-- ... print the file on the default printer.
do shell script "usr/bin/lp " & theFilePath
do shell script "/bin/sleep 10"
-- Thrash the printed file.
do shell script "/bin/rm " & theFilePath
end repeat
end adding folder items to
-
- Mac Mechanic
- Posts: 172
- Joined: Thu Mar 17, 2011 1:46 am
Re: Problem with printing via Folder action script ...
Thanks for the cue ... Do you know how to script move the print file to the trash rather than deleting it ?
- Ronald P. Regensburg
- Expert User
- Posts: 7835
- Joined: Thu Feb 09, 2006 10:24 pm
- Location: Amsterdam, Netherlands
Re: Problem with printing via Folder action script ...
Code: Select all
on adding folder items to thisFolder after receiving theseItems
-- For each file of this folder ...
repeat with i in theseItems
-- ... if the file name is not ".DS_Store" ...
if the name of i is not ".DS_Store" then
-- ... define the file path and ...
set theFilePath to quoted form of POSIX path of i
-- ... print the file on the default printer.
do shell script "usr/bin/lp " & theFilePath
do shell script "/bin/sleep 10"
-- Then tell Finder to move the printed file to the Trash can.
tell application "Finder"
delete i
end tell
end if
end repeat
end adding folder items to
Last edited by Ronald P. Regensburg on Sun Mar 08, 2015 3:53 pm, edited 4 times in total.
Reason:
Reason:
-
- Mac Mechanic
- Posts: 172
- Joined: Thu Mar 17, 2011 1:46 am
Re: Problem with printing via Folder action script ...
I built my script with the generous help of MacScripter's forum ressources. I thought that maybe you would have an idea about my trashing issue. Thank you ...
As for my FAS conflict problem, what is the best web ressource to help me find out the culprit instead of having to migrate all my data to a brand new user ?
As for my FAS conflict problem, what is the best web ressource to help me find out the culprit instead of having to migrate all my data to a brand new user ?
- Ronald P. Regensburg
- Expert User
- Posts: 7835
- Joined: Thu Feb 09, 2006 10:24 pm
- Location: Amsterdam, Netherlands
Re: Problem with printing via Folder action script ...
I don't know a website for this specific problem and I do not know if it is a conflict.
I understand that the problem exists in your user account only. Things I would try to start with:
1. Login to your account with shift key pressed. That wil disable all login items. See if the problem still exists. If the problem is solved, it is caused by one of the processes that start at login.
2. Uncheck all scripts and folders in Folder Actions Setup and then enable only absolutely needed folder actions one by one, each time trying if using the folder action starts the problem.
3. Remove com.apple.FolderActions.plist and/or com.apple.FolderActionsSetup.plist from ~/Library/Preferences/ then log out and again login.
I understand that the problem exists in your user account only. Things I would try to start with:
1. Login to your account with shift key pressed. That wil disable all login items. See if the problem still exists. If the problem is solved, it is caused by one of the processes that start at login.
2. Uncheck all scripts and folders in Folder Actions Setup and then enable only absolutely needed folder actions one by one, each time trying if using the folder action starts the problem.
3. Remove com.apple.FolderActions.plist and/or com.apple.FolderActionsSetup.plist from ~/Library/Preferences/ then log out and again login.
-
- Forum All-Star
- Posts: 1726
- Joined: Tue Oct 14, 2008 12:12 am
Re: Problem with printing via Folder action script ...
There was a question earlier about deleting a file after printing it. The command
deletes the file after printing to the default printer. No need for a separate command to delete the file.
Code: Select all
lpr -r filename
-
- Forum All-Star
- Posts: 1726
- Joined: Tue Oct 14, 2008 12:12 am
Re: Problem with printing via Folder action script ...
Also, here's a routine I found useful for dealing with files that print-to-disk slowly from SheepShaver. It helps prevent the script from printing the file to the actual printer before SheepShaver has finished writing to disk:
Code: Select all
set DELAY_TIME_SECONDS to 1.5 --place this line near the top of the script for easy modifications; experiment with the number
repeat with i in theseItems -- theseItems are the files that the script watches for
set thisFile to i as alias
set fileString to (thisFile as string)
if fileString ends with ".ps" then
set oldSize to 0
set newSize to -1
-- When newSize equals oldSize, the file-copy is complete because the size hasn't changed
repeat while newSize ≠ oldSize
-- Get the file size.
tell application "System Events" to set oldSize to physical size of disk item fileString
delay DELAY_TIME_SECONDS
-- Sample the size again after delay for comparison.
tell application "System Events" to set newSize to physical size of disk item fileString
end repeat
do shell script "lpr -r " & quoted form of POSIX path of thisFile
else
return
end if
end repeat
- Ronald P. Regensburg
- Expert User
- Posts: 7835
- Joined: Thu Feb 09, 2006 10:24 pm
- Location: Amsterdam, Netherlands
Re: Problem with printing via Folder action script ...
Yes, our old print scripts did something like that. (I do not remember who provided those scripts, did you?)
Those scripts did not use System Events to get the file size, they use the equivalent of: Any reason to make use of System Events instead?
Those scripts did not use System Events to get the file size, they use the equivalent of:
Code: Select all
set oldSize to size of (info for thisFile)
-
- Mac Mechanic
- Posts: 172
- Joined: Thu Mar 17, 2011 1:46 am
Re: Problem with printing via Folder action script ...
Good morning Ronald,
Did all your 3 suggestions ... and no change. When printing from SheepShaver, FAD's memory usage starts building. That probably means that FAS is trying to execute the script but cannot. The buildup is probably caused by multiple tries to print. If FAD is forced to quit FAD
Dragging a file to a FAS folder on the desktop, your simplified script does not work while mine does.
And for Emendelson's suggestion do you think it could help with my case ? If yes, how do you insert it in my script ?
Thanks again for all your generous help.
Robert
Did all your 3 suggestions ... and no change. When printing from SheepShaver, FAD's memory usage starts building. That probably means that FAS is trying to execute the script but cannot. The buildup is probably caused by multiple tries to print. If FAD is forced to quit FAD
Dragging a file to a FAS folder on the desktop, your simplified script does not work while mine does.
And for Emendelson's suggestion do you think it could help with my case ? If yes, how do you insert it in my script ?
Thanks again for all your generous help.
Robert
- Ronald P. Regensburg
- Expert User
- Posts: 7835
- Joined: Thu Feb 09, 2006 10:24 pm
- Location: Amsterdam, Netherlands
Re: Problem with printing via Folder action script ...
If the issue is caused by slow writing of the file to the print folder, yes, emendelson's suggestion would be the solution. I could not make his code work in a script here, but this one uses the same principle and it works on my machine:
Edit: To be sure, you do use a desktop printer in SheepShaver to print to a postscript (.ps) file that is saved in the print folder in "Unix"?
Code: Select all
property DELAY_TIME_SECONDS : 1.5 -- How long to wait between checking file size.
on adding folder items to TheFolder after receiving fileList
set thisFile to (item 1 of fileList) as alias
set fileString to (thisFile as string)
if fileString ends with ".ps" then
repeat with f in fileList
set oldSize to 0
set newSize to -1
-- When newSize equals oldSize, copy is complete because the size hasn't changed
repeat while newSize ≠ oldSize
-- Get the file size.
set oldSize to size of (info for f)
delay DELAY_TIME_SECONDS
-- Sample the size again after delay for comparison.
set newSize to size of (info for f)
end repeat
do shell script "lpr -r " & quoted form of POSIX path of f
end repeat
end if
end adding folder items to
Last edited by Ronald P. Regensburg on Mon Mar 09, 2015 2:40 pm, edited 1 time in total.
- Ronald P. Regensburg
- Expert User
- Posts: 7835
- Joined: Thu Feb 09, 2006 10:24 pm
- Location: Amsterdam, Netherlands
Re: Problem with printing via Folder action script ...
Yes, you did here: http://www.emaculation.com/forum/viewto ... 236#p31236Ronald P. Regensburg wrote:I do not remember who provided those scripts, did you?
(For anyone who wants to try that one, it does not work anymore since OSX 10.9. The "Printer Setup Utility", that was already moved from the Utilities folder to CoreServices, does not exist anymore in 10.9 and later.)
-
- Forum All-Star
- Posts: 1726
- Joined: Tue Oct 14, 2008 12:12 am
Re: Problem with printing via Folder action script ...
I'd forgotten all about that! I don't use Folder Action Scripts any longer, because launch daemons are much faster, though they're trickier to set up. My Sheepshaver-based system for running WordPerfect creates the required plist file when Sheepshaver starts up, and the plist launches the script. Possibly my script fragment didn't work because I reworked the original for the launch daemon version.Ronald P. Regensburg wrote:Yes, you did here: http://www.emaculation.com/forum/viewto ... 236#p31236Ronald P. Regensburg wrote:I do not remember who provided those scripts, did you?
(For anyone who wants to try that one, it does not work anymore since OSX 10.9. The "Printer Setup Utility", that was already moved from the Utilities folder to CoreServices, does not exist anymore in 10.9 and later.)
Yes, that is exactly what I do.Ronald P. Regensburg wrote:To be sure, you do use a desktop printer in SheepShaver to print to a postscript (.ps) file that is saved in the print folder in "Unix"?
Last edited by emendelson on Tue Mar 10, 2015 2:09 am, edited 1 time in total.
-
- Mac Mechanic
- Posts: 172
- Joined: Thu Mar 17, 2011 1:46 am
Re: Problem with printing via Folder action script ...
I don't quite understand the possibilities that launch daemons could have for me ... More, I strictly know nothing about writing code for that.
Is there another way, to print and after delete file from a OS X folder ? Could I setup a routine that would check the content of a folder and when there is a file to print it ? Would that be different from checking for an added file to a folder ?
Could that return a better result than a FAS ? I am only guessing ... without knowing the limits or the possibilities of such routine.
Is there another way, to print and after delete file from a OS X folder ? Could I setup a routine that would check the content of a folder and when there is a file to print it ? Would that be different from checking for an added file to a folder ?
Could that return a better result than a FAS ? I am only guessing ... without knowing the limits or the possibilities of such routine.
-
- Mac Mechanic
- Posts: 172
- Joined: Thu Mar 17, 2011 1:46 am
Re: Problem with printing via Folder action script ...
Ronald wrote that for him FAS works but SheepShaver does not remember the print folder. In my case since FAS does not work, I am left to deactivate FAS and to print a PDF file to a folder and to, later, manually print all files in that folder from the OS X side. I wonder which is worse ? Probably that setting up a print folder for every print job is worse.Ronald P. Regensburg wrote:
My main issue is that the desktop printers do not remember the location inside "Unix" to save the file. That problem started in one of the previous OSX versions (Mavericks?).
- Ronald P. Regensburg
- Expert User
- Posts: 7835
- Joined: Thu Feb 09, 2006 10:24 pm
- Location: Amsterdam, Netherlands
Re: Problem with printing via Folder action script ...
With different threads inside this topic, things are getting a little mixed up. First:
The question about whether you use a desktop printer in SheepShaver to print to a postscript (.ps) file that is saved in the print folder in "Unix" was directed to you (rlesperance).
Did you try if the last script I posted (link below) works for you?
http://www.emaculation.com/forum/viewto ... 114#p50114
Yes, when printing with the desktop printer to a file, I need to browse to the destination folder each time again. The folder action scripts works fine, though. Maybe I should try and set up a new desktop printer and see if the destination sticks.rlesperance wrote:Ronald wrote that for him FAS works but SheepShaver does not remember the print folder.
The question about whether you use a desktop printer in SheepShaver to print to a postscript (.ps) file that is saved in the print folder in "Unix" was directed to you (rlesperance).
Did you try if the last script I posted (link below) works for you?
http://www.emaculation.com/forum/viewto ... 114#p50114