if i write a php script can it work?

Come up with a useful post-processing script? Share it here!
Post Reply
soudlous
Newbie
Newbie
Posts: 9
Joined: November 17th, 2008, 10:51 pm

if i write a php script can it work?

Post by soudlous »

if i write a script in php will it work? I don't understand the exit code stuff,
how does sabnzbd pick it up once php is done?
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: if i write a php script can it work?

Post by shypike »

Any program run by SABnzbd returns some exit code.
Currently this code is ignored, but a future release will handle it.
Whether or not a return code from a PHP script will reach SABnzbd,
depends on whether the PHP program will handle it properly.

I don't know which platform you use, but on Linux/Unix
scripts begin with the shebang #!/bin/php and then such things
as exit codes are taken care of.
soudlous
Newbie
Newbie
Posts: 9
Joined: November 17th, 2008, 10:51 pm

Re: if i write a php script can it work?

Post by soudlous »

i wrote a script that works on my windows xp pc in php.

It works for the directory its in, since this directory is also passed in during the commandline

Im not entirely sure what path sabnzbd passes in, the "completed" directory or the directory
of the actually downloaded file. Maybe this is not being passed in correctly to the script.

How do i paste the code into these forums. when i tried i get post to /index.php not allowed.

I tried putting it in between the code tags but i still get the same error.
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: if i write a php script can it work?

Post by shypike »

The security module of the forum is very panicky about code.
As we're not going to debug your script, there's no need to post it  ;)

If you want to see what parameters you get, just let SABnzbd run the
Sample-PostProc.cmd for a download job.
It will show you what the parameters are.
soudlous
Newbie
Newbie
Posts: 9
Joined: November 17th, 2008, 10:51 pm

Re: if i write a php script can it work?

Post by soudlous »

Ah ok. I understand, i wouldn't want code being injected in my forums also

I was just hoping to share the script with others.

Basically I made a script that uses 7z. It can be recursive or non recursive.
Depends on certain code i have included, if you comment and uncomment certain
things it switches, although, i was thinking of making two functions, one for each.
For timesake i put it all in one function for now.

Well, I think it works so far, im going to run that sample script you mentioned and
i guess once i get the directories passed in and get that exit code working with sab
it'll be good.

Im still not sure how that exit code works unfortunately

if at the end of my php code, i run "exit(0)"; if all goes fine
will sabnzbd pick that up or is it something else i have to write sorry.
Sorry for asking so much, i just don't get it :(.

Thanx for the help though. Again i wasn't trying to hack the forums,
I just wanted to share it with others and maybe even get improvements done.

Maybe i can attach it as a .txt file? I'll try later.
User avatar
switch
Moderator
Moderator
Posts: 1380
Joined: January 17th, 2008, 3:55 pm
Location: UK

Re: if i write a php script can it work?

Post by switch »

Attaching the script as a txt file should work, or submit it to the various paste sites such as pastebin.com and pastebin.ca
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: if i write a php script can it work?

Post by shypike »

soudlous wrote: if at the end of my php code, i run "exit(0)"; if all goes fine
will sabnzbd pick that up or is it something else i have to write sorry.
Sorry for asking so much, i just don't get it :(.
That's the right way, but the current releases of SABnzbd will ignore the code.
We'll change that later.
Also, the script runs at the very end of post-processing, so there's not very
much that SABnzbd can do with the exit code, but we will show it in the
history in a later release.
Post Reply