FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Queuing at job from within php program?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Queuing at job from within php program? [message #175670 is a reply to message #175669] Mon, 17 October 2011 18:27 Go to previous messageGo to previous message
Robert Heller is currently offline  Robert Heller
Messages: 60
Registered: December 2010
Karma:
Member
At Mon, 17 Oct 2011 12:47:08 -0400 Jerry Stuckle <jstucklex(at)attglobal(dot)net> wrote:

>
> On 10/17/2011 11:51 AM, bobm3(at)worthless(dot)info wrote:
>> On Mon, 17 Oct 2011 11:20:38 -0400, Jerry Stuckle wrote:
>>
>>> On 10/17/2011 9:24 AM, bobm3(at)worthless(dot)info wrote:
>>>> Fellow php'ers;
>>>>
>>>> I'm having some difficulty getting this to work: Based on a date/time
>>>> selected by a user on a web form I would like to use the "at" command
>>>> to schedule that task.
>>>>
>>>> I've tried various php functions (system, exec, passthru) with the same
>>>> results (return code 1 - which I cannot seem to get the error message
>>>> from).
>>>>
>>>> Here is a sample code snippet:
>>>>
>>>> $cmd = "echo \"podcast -c $filename\" | at $hr:$mn $_ampm";
>>>> passthru("$cmd", $Retcode);
>>>> echo "$Retcode";
>>>>
>>>> returns 1
>>>>
>>>> Then I thought that perhaps the 'at' was not reading stdin in this case
>>>> so I tried a temporary file approach:
>>>>
>>>> $cmd = "echo \"podcast -c $filename\"";
>>>> file_put_contents($filename.tmp, $cmd); passthru("at $_hr:$_mn $_ampm<
>>>> $filename.tmp", $_RetVal); echo "$_RetVal";
>>>>
>>>> This time it returned 2
>>>>
>>>> I've got to be misunderstanding this function. So, I thought if any of
>>>> you skilled readers have had luck with doing something like this you
>>>> may be willing to share. However, any other suggestions greatly
>>>> appreciated.
>>>>
>>>> Thanks
>>>
>>>
>>> What is actually in $cmd when you execute the passthru command?
>>>
>>> What happens when you type this exact output at a command line prompt?
>>
>> I've echoed out the contents of $cmd in my testing. It does contain
>> exactly what is intended:
>> echo "podcast -c abc123 | at 10:01 am"
>>
>> Also, the command I'm trying to execute works perfectly from the CLI with
>> the same (appropriate) values.
>>
>> I'm thinking that there might be a permissions issue but I'm unable to
>> obtain the error message from the passthru command.
>>
>> I suppose next I will try to create a small php script to emulate this
>> from the CLI and perhaps them I will see the error (if any).
>>
>> Thanks
>
> OK, when you enter that exactly from the CLI it works? Are you
> executing it as root or another user?
>
> Next: the home directory for the web server will be different than the
> one from the CLI. Also, the web server will have different permissions.
> Usually the web server user will not have permission to access the
> atjobs directory (/var/spool/cron/atjobs on Debian).
>
> Try su'ing (or sudo'ing) to the web server's id, change to the web
> server's root directory and execute the command.

On a *typical* (eg properly secured) LAMP server, the web server would
be running as the user 'apache' and the apache user's shell will be set
to '/sbin/nologin'. This means that the web server user cannot login to
a shell. This implies that you cannot fork() a *shell*:

sauron.deepsoft.com% sudo su apache -l
This account is currently not available.

In order to run an at command, you need to fork() a shell process.


--
Robert Heller -- 978-544-6933 / heller(at)deepsoft(dot)com
Deepwoods Software -- http://www.deepsoft.com/
() ascii ribbon campaign -- against html e-mail
/\ www.asciiribbon.org -- against proprietary attachments
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: declaring private variable in class
Next Topic: simple session question
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 10 16:38:31 GMT 2024

Total time taken to generate the page: 0.04982 seconds