Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I'm writing a REST application which interacts with an Asterisk server. When I write a test script and run it as sudo root, unlink works fine. However, when I use WWW::Mechanize to run my code across port 80, presumably as www-data, it is able to write a call file to my queue directory with permissions:

drwxrwsr-x 2 www-data www-data 48 2009-09-01 03:18 queue
and then to move that call file to the outbound spool:

drwxrwxr-x 2 root dialer 48 2009-09-01 10:24 outgoing
(www-data is a member of the dialer group.)

That call file is picked up from the spool and used by asterisk (running as root, according to `ps`) to initiate an outbound call and connect it to an extension in my dialplan. The dialplan includes an AGI() call to a script (again running as root if my debug statements for $< and $> are to be believed), which initiates additional calls, staged in the pending queue, and successfully moved to the spool.

The issue arises when one of those calls is successfully connected and bridged to the first. At that point, any still pending call files are supposed to be moved aside before they also get moved to the outbound spool. I've tried unlink "$queue/$call_file" and rename "$queue/$call_file", "$queue/pending/$call_file", and neither seems to work as advertised. Neither seems to be able to successfully remove or move aside those pending call files and the calls keep coming.

Based on speculation last night in a cb conversation, I experimented unsuccessfully with adding the --no-lock option to File::Util->write_file() call used to write the call file originally, hoping that releasing it in that way might free it up for the next process to remove the file. But that did not work either.

Does anyone have any idea what might be missing here? I was at this issue for an hour or more last night without being able to move it forward.

-- Hugh

UPDATE:

Thank you folks. I had been using a foreach to loop over the files returned by a call to File::Utils->list_dir(). The ->list_dir() was looking in the wrong directory, an issue pointed to by an empty debug log when I started looking for the $! output. Thank you kindly.

if( $lal && $lol ) { $life++; }
if( $insurance->rationing() ) { $people->die(); }

In reply to root unable to unlink files by hesco

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2024-03-28 12:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found