how to delete folders from a perl agent - SNMP

This is a discussion on how to delete folders from a perl agent - SNMP ; hi, I'm extending snmp functionality through perl. I've got this in the snmpd.conf ********** pass .1.3.6.1.4.1.2021.255 /home/autom/agent.pl ********** then I've got this in the agent.pl ********* ......... $ruta = "/usr/home/".$parts[1]; `/bin/rm -rf $ruta`; system("/bin/rm -rf $ruta"); $quants = rmtree($ruta,1); ......... ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: how to delete folders from a perl agent

  1. how to delete folders from a perl agent

    hi,

    I'm extending snmp functionality through perl.

    I've got this in the snmpd.conf

    **********

    pass .1.3.6.1.4.1.2021.255 /home/autom/agent.pl

    **********

    then I've got this in the agent.pl

    *********
    .........

    $ruta = "/usr/home/".$parts[1];
    `/bin/rm -rf $ruta`;
    system("/bin/rm -rf $ruta");
    $quants = rmtree($ruta,1);

    .........
    *********

    which i call through snmpset like this:

    *************

    snmpset -v 2c -c mypass 192.168.x.xx .1.3.6.1.4.1.2021.255.8.1.2 s
    "deletehome...test"

    *************

    Well... the thing is that i can't get the script to delete anything in
    /usr/home. I've tried to setuid the agent.pl file, give it 777.
    I've even tried to chown /usr/home/whatever snmp, which will never be
    the case. But still, i can't delete folders. If the folder is empty, i
    can, otherwise, i can't delete recursively.

    Has anyone come up with a solution for this?

    I'm using debian lenny and snmp 5.4.1

    Thanks.

    -------------------------------------------------------------------------
    This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
    Build the coolest Linux based applications with Moblin SDK & win great prizes
    Grand prize is a trip for two to an Open Source event anywhere in the world
    http://moblin-contest.org/redirect.p...r_id=100&url=/
    _______________________________________________
    Net-snmp-users mailing list
    Net-snmp-users@lists.sourceforge.net
    Please see the following page to unsubscribe or change other options:
    https://lists.sourceforge.net/lists/...net-snmp-users


  2. Re: how to delete folders from a perl agent

    hi,

    thanks.

    i will try what you suggest and report back.

    thank you very much.



    En/na Nicholas Jones ha escrit:
    > Use capital R with rm that will remove folders that contain files. So
    > you would need something like:
    > `/bin/rm -Rf /home/`
    >
    > gl,
    > Nicholas Jones
    >
    > On Thu, Aug 28, 2008 at 4:20 AM, Jordi Moles Blanco > > wrote:
    >
    > hi,
    >
    > I'm extending snmp functionality through perl.
    >
    > I've got this in the snmpd.conf
    >
    > **********
    >
    > pass .1.3.6.1.4.1.2021.255 /home/autom/agent.pl
    >
    > **********
    >
    > then I've got this in the agent.pl
    >
    > *********
    > ........
    >
    > $ruta = "/usr/home/".$parts[1];
    > `/bin/rm -rf $ruta`;
    > system("/bin/rm -rf $ruta");
    > $quants = rmtree($ruta,1);
    >
    > ........
    > *********
    >
    > which i call through snmpset like this:
    >
    > *************
    >
    > snmpset -v 2c -c mypass 192.168.x.xx .1.3.6.1.4.1.2021.255.8.1.2 s
    > "deletehome...test"
    >
    > *************
    >
    > Well... the thing is that i can't get the script to delete anything in
    > /usr/home. I've tried to setuid the agent.pl file, give it 777.
    > I've even tried to chown /usr/home/whatever snmp, which will never be
    > the case. But still, i can't delete folders. If the folder is empty, i
    > can, otherwise, i can't delete recursively.
    >
    > Has anyone come up with a solution for this?
    >
    > I'm using debian lenny and snmp 5.4.1
    >
    > Thanks.
    >
    > -------------------------------------------------------------------------
    > This SF.Net email is sponsored by the Moblin Your Move Developer's
    > challenge
    > Build the coolest Linux based applications with Moblin SDK & win
    > great prizes
    > Grand prize is a trip for two to an Open Source event anywhere in
    > the world
    > http://moblin-contest.org/redirect.p...r_id=100&url=/
    >
    > _______________________________________________
    > Net-snmp-users mailing list
    > Net-snmp-users@lists.sourceforge.net
    >
    > Please see the following page to unsubscribe or change other options:
    > https://lists.sourceforge.net/lists/...net-snmp-users
    >
    >
    > ------------------------------------------------------------------------
    >
    > -------------------------------------------------------------------------
    > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
    > Build the coolest Linux based applications with Moblin SDK & win great prizes
    > Grand prize is a trip for two to an Open Source event anywhere in the world
    > http://moblin-contest.org/redirect.p...r_id=100&url=/
    > ------------------------------------------------------------------------
    >
    > _______________________________________________
    > Net-snmp-users mailing list
    > Net-snmp-users@lists.sourceforge.net
    > Please see the following page to unsubscribe or change other options:
    > https://lists.sourceforge.net/lists/...net-snmp-users
    >



    -------------------------------------------------------------------------
    This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
    Build the coolest Linux based applications with Moblin SDK & win great prizes
    Grand prize is a trip for two to an Open Source event anywhere in the world
    http://moblin-contest.org/redirect.p...r_id=100&url=/
    _______________________________________________
    Net-snmp-users mailing list
    Net-snmp-users@lists.sourceforge.net
    Please see the following page to unsubscribe or change other options:
    https://lists.sourceforge.net/lists/...net-snmp-users


+ Reply to Thread