Forum OpenACS Q&A: Re: Can't exec a command in tcl page

Posted by Bjoern Kiesbye on
Hi Antonio,

as others already mentioned, if exec results in an error thrown, it is not a reliable indicator that the executed Program did not finish successful. I have the same problem with wget, when updating the product catalog images. Using it from within tcl exec always throws an error, even if the file was downloaded successful. After wget has finished I check if the tmp file exists, to determine if wget finished successful, see below. I would try to redirect the output of libreoffice to a file, like &>/tmp/libreoffice.log to hopefuly get more details about the actual error.

Out of curiosity, you say you executed the command in a shell and it worked, did you execute the command as the same user running Aolserver?

foreach cur_url $image_urls {
set temp_picture_name [lindex [split "$cur_url" "/"] end]
set temp_picture_file "/tmp/${temp_picture_name}"

if [catch {exec $wget --directory-prefix=/tmp/ "$cur_url"} errmsg] {
ns_write "wget faild : $errmsg"

ns_write "Check if Picture exists!"

if {[file exist $temp_picture_file]} {
ns_write "Picture exists!"

Posted by Antonio Pisano on
Thanks Bjoern,

yes, we considered the possibility of a "fake error" from the command, but this doesn't seem to be the problem. The command actually fails and no output file is created.

I've tried to redirect all the output to a temp file using &>, but the command fails without creating any...

Yes, the command works as expected on the same server both from bash and tclsh.

I was wondering: is there some limitation in privileges for ns_proxy? /tmp/ is world readable, but maybe there are other things ns_proxy is not allowed to do...