Wednesday, 4 August 2010

Shell scripting

This morning I updated my pano website with the panos from Barnsdale Garden. After that I looked at an XMP FileInfo panel someone was having trouble with.

In the afternoon and evening I was trying to write a shell script that would batch process a folder of images, using php to update the database, and ImageMagick to resize the images. I needed some way that php could send data back to the shell script so the shell script could get information needed for executing the ImageMagick commands.

Unfortunately, it seems that you can't set a shell variable from PHP, and have that variable visible in the shell script that called PHP. You can get the output of the PHP script, and assign it to a variable, but if you need more than one variable then you're stuck. I spent quite a while looking into FIFO / named pipes, but couldn't really see how you would use it to send variables to the shell script from PHP.

In the end I decided to just call the existing batch php script from php, very simple, and I was annoyed how I hadn't thought of it before. I found this blog post very helpful: PHP and long running processes.

In the evening I also watched an episode of Star Trek TNG.

No comments: