Running a shell script via applescript on a remote station?
Running a shell script via applescript on a remote station?
- Subject: Running a shell script via applescript on a remote station?
- From: "Patrik B." <email@hidden>
- Date: Fri, 31 Oct 2008 23:37:23 -0800
Hi,
I am working on making the below script work (an image converter via xgrid). However I am running into not being able to spawn the applescript on my remote machine any ideas? (I have WishTCL installed as well as the OSAXplug in, and the xgrid has a dedicated machine with Xgrid running on it. I can see the job being submitted all right via the Xgrid controller and it even "succeeds" but no converted image turns up. Nor do I see the script actually running on the xgrid machine. I beleave the problems lies in spawning the script on the remote machine. Any suggestions on the code below.
This is mostly based on the below blog.
http://jw-digital.net/blog/archives/2006/02/photoshop_xgrid.html
Best, Patrik
--- this is the droplet script to submit images
on open the_files
--copy (choose file with multiple selections allowed) to the_files
set destfolder to choose folder
set myresult to ""
set mypl to PlistOpen alias "G5_1:Users:xgrid1:Desktop:file:batch_template.plist"-- see below
set plCursor to PlistChild mypl key "jobSpecification"
set plCursor to PlistChild plCursor key "taskSpecifications"
set i to -1
repeat with myItem in the_files
tell application "Finder" to set thename to name of file myItem
if thename does not contain ".xmp" then
set myrecord to {POSIX path of myItem, POSIX path of destfolder, "xgrid"}
set i to i + 1
set taskCursor to PlistNewChild {command:"/Volumes/G5_2/test/RAWProcess-XGrid.sh"} at plCursor key i
set argsCursor to PlistNewChild myrecord at taskCursor key "arguments"
end if
end repeat
set mypath to "G5_1:Users:xgrid1:Desktop:Outputlist:batch_out.plist"
do shell script "touch " & POSIX path of "G5_1:Users:xgrid1:Desktop:Outputlist:batch_out.plist"
PlistSave mypl in alias mypath
PlistClose mypl
set scripttext to "xgrid -h localhost -job batch " & POSIX path of "G5_1:Users:xgrid1:Desktop:Outputlist:batch_out.plist"
log scripttext & " loged"
set myresult to do shell script scripttext
log myresult
--tell application "Finder" to delete file "G5_1:Users:xgrid1:Desktop:Outputlist:batch_out.plist"
end open
--------- this is the text of the shell script that the above droplet calls and that should run the applescript on my remote machine but does not
#!/bin/bash
echo "--"
/bin/hostname
echo '
tell application "Finder"
try
mount volume "/Volumes/100.10.10.18"
on error
return "couldnt mount xserve"
exit
end try
try
set rawFile to POSIX file ("'$1'") as alias
set destPath to POSIX file ("'$2'") as alias
on error errText
return "couldnt read files: " & errText
exit
end try
end tell
tell application "Adobe Photoshop CS3"
try
open rawFile showing dialogs never
set myDoc to index of current document
set myResult to save document myDoc as TIFF in destPath
close myResult saving no
on error errText
return "error in photoshop: " & errText
exit repeat
end try
end tell
return "done"
' > /tmp/xgridapplescript
chmod 644 /tmp/xgridapplescript
echo '#!/usr/bin/expect
spawn ssh xgrid@127.0.0.1 "/bin/hostname; osascript /tmp/xgridapplescript"
expect {
"continue*" {
send -- "yes\r"
expect {
"assword*" {
send -- "xgrid\r"
interact
}
}
}
"assword*" {
send -- "xgrid\r"
interact
}
}' > /tmp/xgridscript
chmod 700 /tmp/xgridscript
/tmp/xgridscript $3
rm /tmp/xgridscript
rm /tmp/xgridapplescript
echo "---"
# end of script
------- this is the "batch_out.plist" file that the droplet script above calls for. and that basically gets submitted when the xgrid job gets submitted.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>jobSpecification</key>
<dict>
<key>applicationIdentifier</key>
<string>com.apple.xgrid.cli</string>
<key>inputFiles</key>
<dict/>
<key>name</key>
<string>Image File Process</string>
<key>submissionIdentifier</key>
<string>abc</string>
<key>taskSpecifications</key>
<dict/>
</dict>
</dict>
</plist>
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden