cURL, AFP and Shell Script?

you can test two things:
¢ omit the last slash in the outfolder property line
¢ put parentheses around (quoted form of POSIX path of this_item) and (quoted form of outfolder)

(sigh) i tried both and there was no change

should “theseitems” be “added_items”?

(grasping at straws as usual)

No, the passed parameter must be the same.
Try this stand alone script without event handler to get some error messages.
You have to choose one or more .ps files


property outfolder : "/Users/sawtooth/Desktop/"

-- on adding folder items to thisFolder after receiving theseItems
set theseItems to choose file with multiple selections allowed
repeat with this_item in theseItems
	tell application "Acrobat Distiller 7.0"
		Distill sourcePath quoted form of POSIX path of this_item ¬
			destinationPath quoted form of outfolder ¬
			adobePDFSettingsPath "Standard"
	end tell
end repeat
-- end adding folder items to

when i run the script it asks me to select a doc.

i select the doc and distiller bounces in the dock and gives an error appears

Error

A required component was not found. Please restore
the Adobe Acrobat Distiller folder from the original CD.

Distiller is working fine …without script interaction

are you sure the version number 7.0 is necessary?
Distiller 8 works just with “Acrobat Distiller”

When I compile the script it asks me to select/locate the Distiller Application

Not at work at the moment so no access to my script. But off the top of my head I quote the full POSIX path to the settings file too. Not just its name string. Since V7 I think they reside in path to library & Application Support:Adobe PDF:Foo.joboptions other than that there is nothing else to distiller. I don’t bother with a Folder Action Script just call a loaded handler to process a list.

Thanks Mark.

@sawtooth

OK, the version number seems to be necessary.
The settings parameter is optional, so you can omit it for testing. Maybe that’s the problem

oooooooooook…i had to drop back and punt. the issue of getting distiller to distill has been resolved. i discovered that distiller could watch nested folders…so the distill script wasn’t necessay…i know that’s let down…thank you everyone for your efforts…

if it helps…i have a new problem : )

i want the following script to upload the resulting pdf to a default volume/folder

the script was designed to create a pdf on print (that part works…it uses creator built in pdf function)

  • what doesnt work is uploading the pdf to the volume



property PDFPath : "/Volumes/AD-GRAPHICS/Stuff/"

using terms from application "MultiAd Creator Pro"
	on printed theDoc
		set fileName to name of theDoc
		set destFolder to PDFPath
		
		--Trim off .crtr extension if it has one:
		if fileName ends with ".crtr" then
			set sd to AppleScript's text item delimiters
			set AppleScript's text item delimiters to {"."}
			set fileName to text item 1 of fileName
			set AppleScript's text item delimiters to sd
		end if
		
		tell application "MultiAd Creator Pro"
			export PDF current spread of theDoc saving in (destFolder & fileName & ".pdf") print order user order export method composite resolution limiting 300 black and white compression use zip color image compression use JPEG quality 80 with embed no base 14 fonts, use doc size, binary encoding and compress text and line art without print as spreads, crop marks, registration marks, color bars, document notes, plate information, text blocks only and presentation mode
			set srcPath to quoted form of POSIX path of (destFolder & fileName & ".pdf")
			set dstPath to quoted form of (destFolder & fileName & ".pdf")
			do shell script "/bin/mv " & srcPath & " " & dstPath
		end tell
	end printed
end using terms from


Hi,

I don’t have this app, but try to put the shell script line out of the application tell block

so after/below -end using terms?

no, after end tell

and omit POSIX path of in this line


 set srcPath to quoted form of POSIX path of (destFolder & fileName & ".pdf")

destFolder is already a POSIX path

actually the soultion was even easier than that (with mounted volume)

THIS ONE WORKED : )

again, the pdf creation was not in question but where the results were deposited


property PDFPath : "xxxx:yyyyyyy:"

using terms from application "MultiAd Creator Pro"
	on printed theDoc
		set fileName to name of theDoc
		set destFolder to PDFPath
		
		--Trim off .crtr extension if it has one:
		if fileName ends with ".crtr" then
			set sd to AppleScript's text item delimiters
			set AppleScript's text item delimiters to {"."}
			set fileName to text item 1 of fileName
			set AppleScript's text item delimiters to sd
		end if
		
		tell application "MultiAd Creator Pro"
			export PDF current spread of theDoc saving in (destFolder & fileName & ".pdf") print order user order export method composite resolution limiting 300 black and white compression use zip color image compression use JPEG quality 80 with embed no base 14 fonts, use doc size, binary encoding and compress text and line art without print as spreads, crop marks, registration marks, color bars, document notes, plate information, text blocks only and presentation mode
		end tell
	end printed
end using terms from


The above script works BUT what if I wanted to ftp the results? instead of going to a mounted volume

I assume we would use the cURL shell with properties defining user name etc? ex:



property ftpserverPath : "ftp://123.456.789.99/ftp/folder/"
property user_name : "me"
property pass_word : "me"

	do shell script "/usr/bin/curl " & quoted form of (ftpserverPath & fileName) & " -u " & user_name & ":" & pass_word & " -T " & quoted form of POSIX path of this_item


plus i really do not understand any of the following or how to apply it correctly (or the above for that matter…lol)

does any of this even apply:

set srcPath to quoted form of POSIX path of (destFolder & fileName & “.pdf”)
set dstPath to quoted form of (destFolder & fileName & “.pdf”)
do shell script "/bin/mv " & srcPath & " " & dstPath

way over my head here…all i can think is that srcPath and dstPath should not be same

this should do it



property ftpserverPath : "ftp://123.456.789.99/ftp/folder/"
property user_name : "me"
property pass_word : "me"

	do shell script "/usr/bin/curl " & quoted form of (ftpserverPath & fileName & ".pdf") & " -u " & user_name & ":" & pass_word & " -T " & quoted form of (destFolder & fileName & ".pdf")


i am tired of playing with scripts…lol

for some reason the following didnt work and gave the error:

“There was a problem exporting the file.”

there has to be way to evoke the terminal and upload the results of the pdf export



property ftpPath : "ftp://123.456.789.99//ftp/xxxxxx/"
property user_name : "abcde"
property pass_word : "fghi"

using terms from application "MultiAd Creator Pro"
	on printed theDoc
		set fileName to name of theDoc
		set destFolder to ftpPath
		
		--Trim off .crtr extension if it has one:
		if fileName ends with ".crtr" then
			set sd to AppleScript's text item delimiters
			set AppleScript's text item delimiters to {"."}
			set fileName to text item 1 of fileName
			set AppleScript's text item delimiters to sd
		end if
		
		
		tell application "MultiAd Creator Pro"
			export PDF current spread of theDoc saving in (destFolder & fileName & ".pdf") print order user order export method composite resolution limiting 300 black and white compression use zip color image compression use JPEG quality 80 with embed no base 14 fonts, use doc size, binary encoding and compress text and line art without print as spreads, crop marks, registration marks, color bars, document notes, plate information, text blocks only and presentation mode
			
		end tell
		do shell script "/usr/bin/curl " & quoted form of (ftpPath & fileName & ".pdf") & " -u " & user_name & ":" & pass_word & " -T " & quoted form of (destFolder & fileName & ".pdf")
		
	end printed
end using terms from




I don’t know this application, maybe it doesn’t wait until the PDF has been created completely

I don’ t have your “MultiAd Creator Pro” app but to me you want to be doing the following. Create your PDF locally if and when that process has finished send the file via curl. You have “set destFolder to ftpPath” I could well be wrong but aren’t you telling “MultiAd Creator Pro” to export your PDF to a partial FPT address?

Well I’ve been sat at home bored so I have put this together. I’ve been pretty verbose but it should make sense. I’ve broken each task down to a function and it works thus far for me. I only have a single volume so had to test with cp instead of mv and could not test AFP server mount or FTP transfer. In theory you might well be able to change the properties and uncomment the FTP lines. I can’t test them until Im back in work (bank holiday weekend)

-- Properties Info for AFP
property AFP_Address : "At home so can't test!!!"
property PDF_Path : (path to desktop folder as Unicode text) & "PDF Folder:" -- HFS
property EPS_Path : (path to desktop folder as Unicode text) & "EPS Folder:" -- HFS
-- Properties Info for FTP
property FTP_Address : "ftp://000.000.000.0/Some Folder/Some Folder/"
property User_Name : "Mark"
property User_Password : "Foo"
-- Properties Info for Processing
property Setting_Folder : (path to library folder as Unicode text) & "Application Support:Adobe PDF:Settings:" -- HFS
property Settings_Name : "Press Quality.joboptions"
property Temporary_Path : (path to desktop folder as Unicode text) -- HFS
--
on adding folder items to This_Folder after receiving These_Files
	if Mount_Volume("Macintosh HD") then
		repeat with This_File in These_Files
			set {name:Nm, name extension:Ex} to info for This_File
			if Ex is "pdf" then
				-- if FTP_File(This_File, Nm) then
				if Move_File(This_File, Nm, PDF_Path) then
					if File_Delete(This_File) then
					end if
				end if
				-- end if
			else if Ex is "eps" then
				set Name_Base to Base_Name(This_File)
				if Process_File(This_File, Name_Base) then
					if File_Check((Temporary_Path & Name_Base & ".pdf")) then
						-- if FTP_File((Temporary_Path & Name_Base & ".pdf"), (Name_Base & ".pdf")) then
						if Move_File((Temporary_Path & Name_Base & ".pdf"), (Name_Base & ".pdf"), PDF_Path) then
							if File_Delete((Temporary_Path & Name_Base & ".pdf")) then
							end if
						end if
						if Move_File(This_File, Nm, EPS_Path) then
							if File_Delete(This_File) then
							end if
						end if
						-- end if
					end if
				end if
			else
				display dialog "File \"" & Nm & "\" was not processed!!!" giving up after 3
			end if
		end repeat
	end if
	-- unmount volumes here. (I don't know how to do this)
end adding folder items to
--
on Base_Name(File_Path)
	set Source_Path to quoted form of POSIX path of File_Path
	try
		do shell script "basename" & space & "-s" & space & ".eps" & space & Source_Path
		return result
	on error
		return false
	end try
end Base_Name
--
on Process_File(File_Path, File_Name)
	with timeout of 180 seconds
		tell application "Acrobat Distiller 7.0"
			launch
			delay 5
			Distill sourcePath POSIX path of File_Path ¬
				destinationPath POSIX path of (Temporary_Path & File_Name & ".pdf") ¬
				adobePDFSettingsPath POSIX path of (Setting_Folder & Settings_Name)
		end tell
	end timeout
	return true
end Process_File
--
on File_Check(File_Path)
	-- need some file busy check here not got one here
	delay 10
	return true
end File_Check
--
on Mount_Volume(Volume_Name)
	try
		do shell script "/bin/ls /Volumes"
		if Volume_Name is not in the result then
			mount volume AFP_Address
		end if
		return true
	on error
		return false
	end try
end Mount_Volume
--
on Move_File(File_Path, File_Name, New_Path)
	set Source_Path to quoted form of POSIX path of File_Path
	set Destination_Path to quoted form of POSIX path of (New_Path & File_Name)
	try
		do shell script "/bin/mv" & space & Source_Path & space & Destination_Path
		-- do shell script "/bin/cp" & space & Source_Path & space & Destination_Path
		return true
	on error
		return false
	end try
end Move_File
--
on FTP_File(File_Path, File_Name)
	set Source_Path to quoted form of POSIX path of File_Path
	set Destination_Path to quoted form of POSIX path of (FTP_Address & File_Name)
	try
		do shell script "/usr/bin/curl" & space & Destination_Path & space & "-u" & space & User_Name & ":" & User_Password & space & "-T " & Source_Path
		return true
	on error
		return false
	end try
end FTP_File
--
on File_Delete(File_Path)
	set Source_Path to quoted form of POSIX path of File_Path
	try
		do shell script "rm -f" & space & Source_Path
		return true
	on error
		return false
	end try
end File_Delete

Wow Mark! - I would like to see what you do when you aren’t bored! I will take a better look at your masterpiece later today. It may however be over my head…but at glance…it looked like I could follow it.

As far as the previous questions are concerned (from you and Stefan)

What the original script did was simply tell Creator Pro to create a PDF from the current document (Creator has the ability to create its own PDF’s) using a set of parameters and then save the file to where ever.

The script did work and I could save it to mounted volume.

I thought I would take it one step further and see if it could be tweaked to send to our FTP location (without the use of a hot folder mounted to the desktop -Stefan helped witha folder action script which uploaded the input files to the FTP site)

I thought it would be easy (obviously I was wrong : )

Just for referance - the following script created the PDF and placed it in a mounted volume>folder




property PDFPath : "xxxx:yyyyyyy:"


--this tells Creator Pro to do something when a document is printed-the first comand says the file name is the name of the current document and the destination of the final PDF is PDFpath
using terms from application "MultiAd Creator Pro"
   on printed theDoc
       set fileName to name of theDoc
       set destFolder to PDFPath
       
       --Trim off .crtr extension if it has one:
       if fileName ends with ".crtr" then
           set sd to AppleScript's text item delimiters
           set AppleScript's text item delimiters to {"."}
           set fileName to text item 1 of fileName
           set AppleScript's text item delimiters to sd
       end if
       
-- this tells MultiAd Creator Pro to export the PDF, where to save it and what parameters to use to create it
       tell application "MultiAd Creator Pro"
           export PDF current spread of theDoc saving in (destFolder & fileName & ".pdf") print order user order export method composite resolution limiting 300 black and white compression use zip color image compression use JPEG quality 80 with embed no base 14 fonts, use doc size, binary encoding and compress text and line art without print as spreads, crop marks, registration marks, color bars, document notes, plate information, text blocks only and presentation mode
       end tell
   end printed
end using terms from



I thought it would be as easy as changing the PDFpath to the FTP ip with final folder, defining the user name and password …and then applying the shell script

do shell script "/usr/bin/curl " & quoted form of (ftpserverPath & fileName) & " -u " & user_name & “:” & pass_word & " -T " & quoted form of POSIX path of this_item

but i guess I was wrong : ) i double checked with IT in regards to the ip address, user name and password.

Thats where I am at…as I said previously I will take a look at the “big” script later today…thanks again : ))