Scripted ShellScript won't run

Post Reply
jan_suhr
Member
Posts: 57
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Scripted ShellScript won't run

Post by jan_suhr »

I have made a script that creates a ShellScript file with commands for PDFToolkit. In this way I can use SwitchVariables for the PDFTK command.

My problem is that this .sh file that Switch generates will not run, I get error [255] in Switch from the ExecuteCommand. If I try to run the same script in Terminal it says "Permission Denied". I guess that is the same as [255] in Switch log.

I have the exactly same .sh file written manually in a text editor and it runs fine, both in Switch and in Terminal. So what is the difference? If I look at the permissions on the .sf-file from Switch everybody has write&read permissions.



Thanks


Jan
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
User avatar
gabrielp
Advanced member
Posts: 577
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: Scripted ShellScript won't run

Post by gabrielp »

I did something similar once (Switch generate a dynamic .sh file and run it) and had to have Switch run chmod 777 script_path on the script before I could execute it.
Chat: open-automation @ gitter
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
jan_suhr
Member
Posts: 57
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: Scripted ShellScript won't run

Post by jan_suhr »

Thanks that solved it!


Jan
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
jan_suhr
Member
Posts: 57
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: Scripted ShellScript won't run

Post by jan_suhr »

Well, working some more with this flow and script there is still a problem with the resulting PDF that PDFtk generates from the Shellscript. Switch will not write the resulting file to the output folder. I get no errors in the log, it just don't output the file. I suspect that there is some permission issues with the produced file from PDFtk.

Using the manually created script it works and outputs a file.


Jan
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
User avatar
gabrielp
Advanced member
Posts: 577
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: Scripted ShellScript won't run

Post by gabrielp »

How are you determining the path of the output folder?

In Switch scripts, if you want a job to come out of an outbound connection of a script, you need to sent it with a job.sendTo function. That usually means, if your script is creating files, you need to create a new Job, create a File within that job, write to it, then send the job out with a job.sendTo*.

Here are some some troubleshooting ideas for you. Make the generated shell script output some text with something like echo or print. That way, you can see in the exit codes that it is running. Make sure to print the exit codes (stdin and stderr) to the Switch log. Lastly, since you're generating a shell script dynamically, it would be a good idea to send the script contents to the Switch log so you can see what is being generated and run that script externally to test it.
Chat: open-automation @ gitter
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
jan_suhr
Member
Posts: 57
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: Scripted ShellScript won't run

Post by jan_suhr »

Yes I had it set to job.sendToSingle(tempfile)

But there were some other stuff going on there and Jonas at the support helped me get it to work, even for him it was a challenge :-)

Thanks


Jan
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
Post Reply