Perl script to list replicas

Hello,
i have written a perl script which lists all the replicas that reside on
the eDirectory server. I use the function 'ListReplicas' in
Net::LDAP::Extensions::eDirectory - but not all replicas are listed,
from 6 replicas that reside on the server only 4 are listed in the script.
any ideas or another solution?
config:
nw6.5/sp6
perl v5.8.4
Pete

I was thinking about the following if you're just wanting services:
systemctl list-units -t service --no-pager --no-legend | grep active
edit: While I'm here, here's a script I wrote which allows you to manipulate services using a function and dmenu. The final output is piped in monospace font to gxmessage, but of course you can hack this around in lots of ways.
#!/bin/bash
services()
sm="dmenu -l 20 -fn Monospace-8 -p"
s1=$(systemctl list-unit-files -t service --no-legend | $sm Service); s1=${s1/%service*/service}; [[ -z $s1 ]] && exit
s2=$(echo -e "status\nstart\nstop\nrestart\nenable\ndisable" | $sm "Action"); [[ -z $s2 ]] && exit
if [[ $s2 == "status" ]]; then unset s3; else s3="gksudo --"; fi
eval $s3 systemctl --no-pager $s2 $s1 2>&1 | gxmessage -file - -title Services -center -fn "Monospace 8"
services
Last edited by ninian (2012-11-23 00:46:46)

Similar Messages

  • Facing Problem in Perl Script

    Hi ,
    I m facing one problem in perl script.
    Oracle Database 10g.
    DBD::Oracle::db selectall_arrayref failed: handle 2 is owned by thread 225ffc not c
    urrent thread 1c4f8ac (handles can't be shared between threads and your driver may
    need a CLONE method added) at c:\perl\update_card_numbers_oracle.pl line 258, <STDI
    N> line 1.
    Thx in advance....

    There are forums here at OTN for Perl related issues ... this isn't it.
    Return to the list of all forums and find the one where your inquiry belongs.

  • How to run NMS perl scripts in SunONE 6.1

    Any one have info on running the NMS perl scripts with the perl compiler shipped with 6.1? Particularly interested in nms FormMail. I need to get it running in on windows xp and Sun Solaris.
    WebServer is reporting the following error.
    failure: for host dbmrpm41.deluxe.com trying to POST /cgi-bin/FormMail.pl, cgi_s
    can_headers reports: HTTP4044: the CGI program C:\Sun\WebServer6.1\bin\https\per
    l\perl.exe did not produce a valid header (program terminated without a valid CG
    I header. Check for core dump or other abnormal termination)
    When I run FormMail.pl in a command prompt, I receive the following:
    Can't locate auto/POSIX/autosplit.ix in @INC (@INC contains: C:/Sun/WebServer6.1
    /bin/https/perl/lib/MSWin32-x86 C:/Sun/WebServer6.1/bin/https/perl/lib) at C:/Su
    n/WebServer6.1/bin/https/perl/lib/AutoLoader.pm line 146.
    at C:/Sun/WebServer6.1/bin/https/perl/lib/MSWin32-x86/POSIX.pm line 5
    Edited by: garyb on Mar 18, 2008 9:04 AM

    The Perl you found in the bin/https/perl directory is a private copy of Perl used to implement parts of the Web Server Administration Server. You shouldn't try to use it to run CGI scripts.
    Instead, you can download your own Perl distribution. ActiveState has a Perl distribution called ActivePerl. You can get it for free from http://www.activestate.com/Products/activeperl/. Other options are listed at http://win32.perl.org/.

  • Rman/PERL scripts errors

    I am trying to automate the backups and disk maintenence on a test machine using a "Host Command" in the 10g EM environment. If I run the script from the command on the target host the scripts completes successfully.
    This is the script:
    ORACLE_HOME=/u01/app/oracle/product/9.2.0
    export ORACLE_HOME
    ORACLE_SID=coeusdba.
    export ORACLE_SID
    rman <<EOF
    connect target sys<password>@coeusdba;
    connect catalog <user>/<password>@recv;
    replace script coeusdba_full_bkp { 
    allocate channel Channel1 type disk format '/u03/orabkp/coeusdba/b_%u_%p_%c';
    backup
    ( database include current controlfile );
    backup ( archivelog all delete input );
    run { execute script coeusdba_full_bkp;}
    EOF
    /u01/app/oracle/product/9.2.0/dbs/scripts/coeusdba_new.sh
    exit
    When I execute the same script from a 10g EM "Host Command" job the script fails at the PERL command step with the following output:
    Recovery Manager: Release 9.2.0.7.0 - Production
    Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.
    RMAN>
    RMAN>
    connected to target database: COEUSDBA (DBID=1916078485)
    RMAN>
    RMAN>
    connected to recovery catalog database
    RMAN> 2> 3> 4> 5> 6> 7> 8>
    replaced script coeusdba_full_bkp
    RMAN>
    RMAN>
    executing script: coeusdba_full_bkp
    allocated channel: Channel1
    channel Channel1: sid=10 devtype=DISK
    Starting backup at NOV-01-2005 10:32:32
    channel Channel1: starting full datafile backupset
    channel Channel1: specifying datafile(s) in backupset
    including current controlfile in backupset
    input datafile fno=00006 name=/u02/oradata/coeusdba/users01.dbf
    input datafile fno=00002 name=/u03/oradata/coeusdba/undotbs01.dbf
    input datafile fno=00004 name=/u03/oradata/coeusdba/index01.dbf
    input datafile fno=00005 name=/u03/oradata/coeusdba/tools01.dbf
    input datafile fno=00007 name=/u03/oradata/coeusdba/xdb01.dbf
    input datafile fno=00001 name=/u02/oradata/coeusdba/system01.dbf
    input datafile fno=00003 name=/u02/oradata/coeusdba/drsys01.dbf
    channel Channel1: starting piece 1 at NOV-01-2005 10:32:33
    channel Channel1: finished piece 1 at NOV-01-2005 10:33:28
    piece handle=/u03/orabkp/coeusdba/b_3rh2l4q1_1_1 comment=NONE
    channel Channel1: backup set complete, elapsed time: 00:00:55
    Finished backup at NOV-01-2005 10:33:28
    Starting backup at NOV-01-2005 10:33:29
    current log archived
    channel Channel1: starting archive log backupset
    channel Channel1: specifying archive log(s) in backup set
    input archive log thread=1 sequence=49 recid=200 stamp=573215609
    channel Channel1: starting piece 1 at NOV-01-2005 10:33:32
    channel Channel1: finished piece 1 at NOV-01-2005 10:33:33
    piece handle=/u03/orabkp/coeusdba/b_3sh2l4rr_1_1 comment=NONE
    channel Channel1: backup set complete, elapsed time: 00:00:02
    channel Channel1: deleting archive log(s)
    archive log filename=/u04/arch/coeusdba/1_49.dbf recid=200 stamp=573215609
    Finished backup at NOV-01-2005 10:33:35
    Starting Control File and SPFILE Autobackup at NOV-01-2005 10:33:35
    piece handle=/u04/orabkp/coeusdba/ctl_file_bkps/c-1916078485-20051101-00 comment=NONE
    Finished Control File and SPFILE Autobackup at NOV-01-2005 10:33:38
    released channel: Channel1
    RMAN>
    RMAN>
    Recovery Manager complete.
    syntax error at /u01/app/oracle/product/9.2.0/EM10g_1/perl/lib/5.6.1/warnings.pm line 306, near "{^"
    syntax error at /u01/app/oracle/product/9.2.0/EM10g_1/perl/lib/5.6.1/warnings.pm line 311, near "{^"
    BEGIN failed--compilation aborted at /u01/app/oracle/product/9.2.0/EM10g_1/perl/lib/5.6.1/English.pm line 38.
    BEGIN failed--compilation aborted at /u01/app/oracle/product/9.2.0/dbs/scripts/rmanc.pl line 20
    Is anyone having this problem in 10g and if so , can you provide me with some insight with respect to resolution?

    The .sh script calls a perl script that parses the output of the report obsolete command in rman and deletes the obsolete datasets from disk. This shell completes from the command line with no errors. Here is the .sh and the perl script. Like I said the odd thing is that this shell executes successfully from the command line. Thanks for your interest in looking at this.
    cat coeusdba_new.sh
    /u01/app/oracle/product/9.2.0/dbs/scripts/rmanc.pl target sys/<password>@coeusdba catalog rmantest/<password>@recv redundancy 2
    rmanc.$ cat rmanc.pl
    #!/usr/bin/perl -w
    # NAME
    # rmanc.pl - delete obsolete backups and copies
    # DESCRIPTION
    # This perl script automates deletion of obsolete datafilecopies and
    # backup pieces. It uses perl strin manipulation to process the output of the RMAN
    # "report obsolete" command and creates rm commands to delete the files
    # NOTES
    # Some customization is necessary.
    # Adapted from Oracle 8i rman1.sh Unix shell script.
    # benmalek 03/08/2003 - Modified to delete backup sets and datafilecopies only
    # Does not touch backup records.
    use strict;
    #use English;
    #$ENV{ORACLE_OWNER}='oracle';
    #$ENV{ORACLE_HOME}='/disk01/app/oracle/product/9.2.0';
    $ENV{NLS_DATE_FORMAT}='DD-MON-YYYY:HH24:MI:SS';
    &PrintEnv;
    sub Usage {
    my ($arg1, @arg2) = @_;
    my $base_name = `basename $0`;
    chop($base_name);
    CASE: {
    if (!defined($arg1)) {last CASE; }
    if ($arg1 =~ /\S/) {print ("\nUnknown argument or incorrect value for: $arg1\n\n"); last CASE; }
    my $example1 = 'rmanc.pl target sys/orclpass@orcl catalog rman/rmanpass@rec redundancy 5';
    my $example2 = 'rmanc.pl target sys/orclpass@orcl nocatalog redundancy 5';
    my $usage_txt =
    " Usage: $base_name [option] ...
    option: [target CNCTSTR] [catalog CNCTSTR | nocatalog] [params 'PARMS'] [redundancy NUMBER]
    Option Description
    target CNCTSTR Connect to the target db using CNCTSTR.
    catalog CNCTSTR Connect to catalog db using CNCTSTR.
    nocatalog Don't use a recovery catalog.
    parms 'PARMS' Use PARMS string for SBT_TAPE maintenance channel.
    You can use single or double quotes depending on
    your needs. In the rman script, single-quotes
    will be used.
    redundancy NUMBER Set redundancy of backups to NUMBER.
    The catalog or nocatalog option must be specified. All others are optional
    The target option must also be specified
    Examples:
    $example1
    $example2 ";
    print ("$usage_txt \n");
    die "Exiting subroutine 'Usage'.\n";
    # Initialize default connect string variables:
    my $target=""; # force user to supply target option
    my $catalog=""; # force user to supply catalog option;
    my $parms="";
    my $redun=""; # force user to supply redundancy option;
    # process target and catalog arguments
    my $args = @ARGV;
    while ( $args > 0 ) {
    ARGS: {
    if (($ARGV[0] eq "target") && defined($ARGV[1]))
    {$target="$ARGV[0] $ARGV[1]"; shift(@ARGV); last ARGS;}
    if (($ARGV[0] eq "catalog" || $ARGV[0] eq "rcvcat") && defined($ARGV[1]))
    { $catalog="$ARGV[0] $ARGV[1]"; shift(@ARGV); last ARGS;}
    if ($ARGV[0] eq "nocatalog") { $catalog="$ARGV[0]"; last ARGS;}
    if (($ARGV[0] eq "parms") && defined($ARGV[1])) { $parms = "$ARGV[0] $ARGV[1]"; shift(@ARGV); last ARGS;}
    if (($ARGV[0] eq "redundancy") && defined($ARGV[1]) && !($ARGV[1] =~ /\D/))
    {$redun=$ARGV[1]; shift(@ARGV); last ARGS;}
    &Usage($ARGV[0]);
    shift(@ARGV);
    $args= @ARGV;
    if ((!defined($catalog) || $catalog eq "") || (!defined($target) || $target eq "") || (!defined($redun) || $redun eq "" )) {&Usage;}
    #print (" target=$target \n catalog=$catalog \n parms=$parms \n redundancy=$redun\n");
    # Get a list of obsolete disk files to delete:
    my @rman_out=`rman $target $catalog << EOF
    report obsolete redundancy=$redun device type disk;
    exit;
    EOF`;
    # debug
    print ("############################################\n");
    print ("Output of REPORT OBSOLETE REDUNDANCY=$redun\n");
    print @rman_out;
    print ("############################################\n");
    #my $command = `rman $target $catalog << EOF
    # report obsolete redundancy=$redun device type disk;
    # exit;
    # EOF"
    #open (RMAN, "$command |" );
    #my @rman_out=<RMAN>;
    # Extract the names of the obsolete files to delete
    my $line;
    my @files;
    my @dates;
    my @pieces;
    foreach $line (@rman_out) {
    if (($line =~ /Backup Piece/) && ($line =~ /\S/)) {
    my @fields=split (/\s+/, $line);
    my $nelem=@fields;
    push(@pieces, $fields[$nelem-3]);
    push(@dates, $fields[$nelem-2]);
    push(@files, $fields[$nelem-1]);
    # Verify files exists
    my $i=0;
    foreach $line (@files) {
    if (-e $line) {
    print ("Deleting backup piece or file copy: $pieces[$i] $dates[$i] $line\n");
    system("rm $line");
    } else {
    # print ("file $line does not exist. \n");
    $i = $i + 1;
    sub PrintEnv{
    my $var;
    foreach $var (sort keys %ENV) {
    print "$var: \"$ENV{$var}\".\n"
    pl

  • I have perl scripts that I want to be able to run with my iplanet web server 6.0. How can I make it work in Windows NT? (Because I have no problem when I use it with Linux).

     

    Hi Melanie,
    In order to run a PERL script under Windows NT the iPlanet Web Server needs to know where to find the PERL interpreter.
    follow these steps :
    1) Make sure Windows NT knows what a .pl file is. In file Manager click on file and choose associate from the menu. Check the "files with extension" drop-down list for pl - if it exists verify that it is pathed to your perl.exe. If it is not already on the list click the "New Type" button. In the Filetype box put pl. Choose open from the Action drop-down list. In the Command box specify the full path to your perl.exe interpreter (Make sure to use short filenames, rather than long filenames.) Click the OK button. Then click the Close button in the main Associate dialog box. Double click a .pl file to test - it should automatically launch the PERL interpreter and feed it your .pl file.
    2) Create a directory to contain your .pl scripts.
    ~server_root\shell-cgi is a good choice.
    or \cgi-bin\
    NOTE: Make very sure that this directory is NOT part of the document root, it should have it's own directory (preferably at the same level of the docroot).
    3) In the Admin Server select Programs.
    4) Choose CGI directory (normally) or WinCGI directory or ShellCGI Directory depending on ur choice from the Programs menu.
    5) Put the URL Prefix you would like to map to your Shell-CGI directory into the URL Prefix field.
    6) Put the full path to your Shell-CGI directory in the Shell CGI directory field.
    7) Click OK.
    8) The save and apply changes page will display your changes and give you the opportunity to verify them. If they are correct click the Save and Apply button. If not Click the Undo button and go back to step 4.
    (9)You can then call your .pl scripts directly by referencing the directory mapping that you have just created. For example:
    http://my.server.whatever/shell-cgi/ myscript.pl
    this should work now.
    If not Pls Mail me.
    regards
    T.Raghulan
    [email protected]

  • [solved] Perl script for pacman updates in Conky

    Hi
    I've been using this script in Perl Conky to check on updates. It works well.
    It's not mine - I got it here;
    http://bbs.archlinux.org/viewtopic.php?id=57291
    #!/usr/bin/perl
    ## script by Xyne
    ## http://bbs.archlinux.org/viewtopic.php?id=57291
    use strict;
    use warnings;
    my $n = (`pacman -Qu | wc -l`);
    chomp ($n);
    if ($n == 0)
    print "System up to date"
    elsif($n == 1)
    print "1 new package"
    else
    print "$n new packages (inc. IgnorePkg) "
    I have some packages listed in IgnorePkg in pacman.conf - is there a way to exclude them from the packages counted in $n?
    I thought something like this would help but I don't see how to take only part of a line from IgnorePkg
    http://www.perlfect.com/articles/perlfile.shtml
    Thanks for any help
    EDIT I added a --ignore clause to the pacman query. Seems to have worked. Sorry to waste your time.
    Last edited by Bazzaah (2012-07-04 09:25:46)

    bump...
    Edit: Finally figured it out. My router assigns IP adresses dynamically on each reboot. When my IP adress changed from 192.169.1.2 to 192.168.1.3 the hellaconk script got all confused. Ahh...
    Last edited by Perre (2009-03-12 18:59:40)

  • Logconv.pl perl script?

    Anyone familiar witht the logconv.pl perl script that comes with the directory resource kit? Its for access logs. In verbose mode it lists "top 10 clients" and states "unknown host". What is it referring to in the access log for unknown host?

    I think that logconv.pl is trying to match the IP address against a host name.
    This is in the "LDAP connection from" lines in the access logs.
    Regards,
    Ludovic.

  • Perl script issue.

    Hi,
    How do I properly install the Perl modules as listed below for
    OES2SP2/SLES10SP3- SendMail.pm, MIME*?
    Do I use YAST,CPAN.org, 'make install'?
    I just moved a NetWare Perl script over to OES2SP2/SLES10SP3.
    The script fails because of missing SendMail.pm
    Can't locate Mail/SendMail.pm in @INC (@INC contains:
    //usr/lib/perl5/5.8.8/x86_64-linux-thread-multi
    I have reviewed this link and it states:
    http://www.tneoh.zoneit.com/perl/SendMail/FAQ.html#Q5
    5) I got error:
    Can't locate SendMail.pm in @INC (@INC contains:
    /usr/lib/perl5/5.6.0/i386-linux /usr/lib/perl5/5.6.0
    /usr/lib/perl5/site_perl/5.6.0/i386-linux /usr/lib/perl5/site_perl/5.6.0
    /usr/lib/perl5/site_perl .) at (eval 6) line 1.
    Ans: Make sure you include the folder where you store those SendMail.pm,
    MIME/Base64.pm and MIME/QuotedPrint.pm files into @INC.
    You can do it with:
    use lib qw(YOUR/FOLDER);

    DrumDude wrote:
    > Simon Flood wrote:
    >> On 10/02/2010 15:30, DrumDude wrote:
    >>
    >>> How do I properly install the Perl modules as listed below for
    >>> OES2SP2/SLES10SP3- SendMail.pm, MIME*?
    >>>
    >>> Do I use YAST,CPAN.org, 'make install'?
    >>>
    >>> I just moved a NetWare Perl script over to OES2SP2/SLES10SP3.
    >>> The script fails because of missing SendMail.pm
    >>> Can't locate Mail/SendMail.pm in @INC (@INC contains:
    >>> //usr/lib/perl5/5.8.8/x86_64-linux-thread-multi
    >>>
    >>> I have reviewed this link and it states:
    >>> http://www.tneoh.zoneit.com/perl/SendMail/FAQ.html#Q5
    >>> 5) I got error:
    >>> Can't locate SendMail.pm in @INC (@INC contains:
    >>> /usr/lib/perl5/5.6.0/i386-linux /usr/lib/perl5/5.6.0
    >>> /usr/lib/perl5/site_perl/5.6.0/i386-linux /usr/lib/perl5/site_perl/5.6.0
    >>> /usr/lib/perl5/site_perl .) at (eval 6) line 1.
    >>> Ans: Make sure you include the folder where you store those
    >>> SendMail.pm,
    >>> MIME/Base64.pm and MIME/QuotedPrint.pm files into @INC.
    >>> You can do it with:
    >>> use lib qw(YOUR/FOLDER);
    >>
    >> You may find the following Cool Solutions article that I wrote useful
    >> -
    >> http://www.novell.com/communities/no...x-installation
    >>
    >>
    >> As [email protected] noted you can use 'cpan' which is the equivalent of
    >> the perl command at the beginning of my article.
    >>
    >> HTH.
    >
    > Thanks
    > I was actually plugging my way through just that; but Sendmail hangs?
    > What am I missing? How can I edit the test.pl or Sendmail.pm before
    > installation?
    > Thanks
    >
    > Details
    > >>>>>>
    > Checking if your kit is complete...
    > Looks good
    > Writing Makefile for Mail::Sendmail
    > ************************************************** ********************
    >
    > NOTE
    > ----
    >
    > The test (test.pl) is a real test for this module: it sends an e-mail.
    >
    > You may want to edit test.pl before running it (directly or through
    > make test), so the mail is sent to you. If you also leave my address,
    > the mail goes into a database from which I can get statistics.
    >
    > Read the docs, and have fun...
    >
    > ************************************************** ********************
    > cp Sendmail.pm blib/lib/Mail/Sendmail.pm
    > Manifying blib/man3/Mail::Sendmail.3pm
    > /usr/bin/make -- OK
    > Running make test
    > PERL_DL_NONLAZY=1 /usr/bin/perl "-Iblib/lib" "-Iblib/arch" test.pl
    > 1..2
    > Test Mail::Sendmail 0.79
    >
    > Trying to send a message to the author (and/or whoever if you edited
    > test.pl)
    >
    > (The test is designed so it can be run by Test::Harness from CPAN.pm.
    > Edit it to send the mail to yourself for more concrete feedback. If you
    > do this, you also need to specify a different mail server, and possibly
    > a different From: address.)
    >
    > Current recipient(s): 'Sendmail Test <[email protected]>'
    >
    > ok 1
    > Server set to: mail.alma.ch
    > Sending...
    >
    Going to download manually edit the files then install and or copy.

  • Calling the DTExec from Perl Script and need to get the Return Value (Sucess or Failure)

    I am able to execute the SSIS Package from Perl Script using DTExec. But i need to get the return code of the SSIS Execution. Is their any option available to get the Success or Failure information from Perl ?

    Exit codes returned from dtexec utility             
    When a package runs, dtexec can return an exit code. The exit code is used to populate the ERRORLEVEL variable, the value of which can then be tested in conditional statements or branching logic within a batch file. The following table lists
    the values that the dtexec utility can set when exiting.
    http://technet.microsoft.com/en-us/library/hh231187.aspx
    There's a wrinkle if the package is running in the SSIS Catalog:
    http://www.mattmasson.com/2012/02/exit-codes-dtexec-and-ssis-catalog/
    David
    David http://blogs.msdn.com/b/dbrowne/

  • Capture output of Perl script with jsp:include

    The company's main web site has a CGI script written in Perl that generates a header, and another one that generates a footer. I would like to deploy a JSP that incorporates the header and footer without having to re-implement the header/footer Perl code in Java.
    Can the <jsp:include> tag include the output from these Perl scripts?

    Well, I tried it. The answer seems to be no.
    I created a simple CGI hello-world thingie and tested it, works fine from a browser (I'm doing all this remotely on a friend's Gentoo box so I know it's not just cached in my browser or anything).
    Then I created a simple JSP and used a fully-qualified URL pointing to the executable CGI script. While the JSP compiles and renders (I had some text in the JSP itself too), the part where it's supposed to include the content of the Perl script doesn't even appear.
    I also tried putting the CGI script into my webapp directory and specifying a relative path to the script, and it doesn't seem to get executed either. To confirm that I'm doing everything right, I put together a simple HTML file that has the same output and changed the "page" attribute to point to that file instead. Sure enough, the output appears.
    So the answer to my question appears to be: no, the output of a Perl CGI cannot be included into a JSP with the <jsp:include> tag. But I'm going to double-check on the Tomcat-user mailing list.

  • Wanted: script to list uninstalled optdepends and packages that need t

    I had a thought today that a script to list package that are optdepends but not installed could be quite useful...  I have not written one, but thought it would be good for pacman-contrib if someone wanted to contribute.
    Example output:
    tk - optional for:
       ruby - for Ruby/TK
       python - for IDLE, pynche and modulator
    fakeroot - optional for:
       pacman - for makepkg usage as normal user
    So get script writing!  Preferably in bash or perl (which the current pacman-contrib scripts use).

    I cheated and used my perl ALPM module.  I think the logic is sound, though, and you can replace the module calls with backticking pacman (preferably functions wrapping them).  I planned to but ran out of time.
    #!/usr/bin/perl
    use warnings;
    use strict;
    use ALPM ( dbpath => '/var/lib/pacman/' );
    my %reverse_depends;
    my $db = ALPM->register_db;
    OPT_SEARCH:
    for my $pkg ( @{$db->get_pkg_cache} ) {
    my $pkg_optdeps = $pkg->get_optdepends;
    next OPT_SEARCH unless @$pkg_optdeps;
    my $depender = $pkg->get_name;
    my %reason_for = map {
    /\A([^:]*):\s*(.*)/ ? ($1 => $2) : ($_ => '')
    } @$pkg_optdeps;
    DEP_LOOP:
    for my $dependee ( keys %reason_for ) {
    next DEP_LOOP if $db->get_pkg($dependee); #ignore installed
    $reverse_depends{$dependee}->{$depender} = $reason_for{$dependee};
    for my $opt_dep ( sort keys %reverse_depends ) {
    print "$opt_dep\n";
    my $reason_of = $reverse_depends{$opt_dep};
    for my $depender ( sort keys %$reason_of ) {
    my $reason = $reason_of->{$depender};
    print " $depender",
    ( $reason ? ": $reason\n" : "\n" );

  • Folder Action to Launch Perl Script

    Hello.
    I wrote a perl script which I wanted to execute when a file was dropped into a folder. I added a folder action with a very simple applescript:
    on adding folder items to this_folder after receiving added_items
    do shell script ¬
    ("perl /Users/Alexander/Library/Scripts/gte2.pl")
    end adding folder items to
    The folder action didn't do anything, any thoughts on what I'm doing wrong? Note, the perl script works fine when I run it from the terminal.
    thanks.

    Thanks Camelot, I appreciate the help. My script below is trying to read data from a file in folder in my system. So I will try your suggestion, I didn't realize the environment and path my be different.
    Regards Alex
    #!/usr/bin/perl -w
    #This program is to convert files from gamin running GPS watch to text file which can be loaded into excel.
    # To make executable, remember to set: chmod u+x <file>
    #set all the flags. Note the flags are used to stop the matching
    $i = 1; $k = 0; $start = "no";
    #Open data file and find values
    open(DATA,"/Users/Alexander/Alex's Misc/Health/Garmin_Conversion/run.tcx") || die "Couldn't open file*\n";
    #read in the data line by line until "end of file"
    while (<DATA>){
    #start parsing for information to keep
    if (/.<Id>./) {
    @Idline=split(/>/);
    @Idbeat=split(/T/,$Idline[1]);
    $Id=$Idbeat[0];
    if (/.<Track>./){
    $start = "yes";
    if ($start eq "yes"){
    if (/.<Time>./) {
    @timeline=split(/T/);
    @timebeat=split(/Z/,$timeline[2]);
    $Time[$i]=$timebeat[0];
    elsif (/.<LatitudeDegrees>./) {
    @HRline=split(/>/);
    @HRbeat=split(/</,$HRline[1]);
    $Latitude[$i]=$latbeat[0];
    elsif (/.<LongitudeDegrees>./) {
    @longline=split(/>/);
    @longbeat=split(/</,$longline[1]);
    $Longitude[$i]=$longbeat[0];
    elsif (/.<AltitudeMeters>./) {
    @altline=split(/>/);
    @altbeat=split(/</,$altline[1]);
    $Altitude[$i]=$altbeat[0];
    elsif (/.<DistanceMeters>./) {
    @distline=split(/>/);
    @distbeat=split(/</,$distline[1]);
    $Distance[$i]=$distbeat[0];
    elsif (/.<Value>./) {
    @HRline=split(/>/);
    @HRbeat=split(/</,$HRline[1]);
    $HR[$i]=$HRbeat[0];
    $i++;
    } #string matching
    } #if start flag is yes
    } #while data loop
    close (DATA) || die "couldn't close file.\n";
    #write all data to file in space delimited format
    open (NEWFILE, ">/Users/Alexander/Alex's Misc/Health/Garmin_Converted/$Id run") || die "can't create file.\n";
    $Time[0]="Time"; $Latitude[0]="Latitude"; $Longitude[0]="Longitude"; $Altitude[0]="Altitude"; $Distance[0]="Distance"; $HR[0]="HR";
    print NEWFILE "0 $Time[0] $Latitude[0] $Longitude[0] $Altitude[0] $Distance[0] $HR[0]\n";
    for ($j = 1; $j <= $i; $j++) {
    $k=$j+1;
    print NEWFILE "$j $Time[$j] $Latitude[$j] $Longitude[$j] $Altitude[$j] $Distance[$j] $HR[$j]\n";
    } #for j loop
    close (NEWFILE) || die "couldn't close newfile.\n";
    #This is the end of the program

  • How to launching a perl script by the "begin" script of a jumpstart

    Hi all,
    i have an urgent pb with my solaris jumpstart, let me explain to you :
    i want that the begin script launch some perl script, but i have a problem
    here is my "begin" script:
    echo "Begining ISO FLAR based jumpstart."
    echo ""
    echo "Starting Ullink Configuration"
    env > /tmp/env
    /bin/sh << EOF
    /usr/bin/perl /cdrom/.archives/admin-scripts/sethostname.pl
    EOFmy perl script use a STDIN
    with this configuration, the perl script is launching but it runs in a loop indefinitely with an error "use of uninitialized value", because (i think) a value is return to the begin scritp and not to the perl script.
    well, on a pre-installed solaris, if a launch the begin script, it happens the same thing, it runs in a loop, BUT if i comment the line "/bin/sh <<EOF" and "EOF", it works.
    at this step, i say "ok it's cool my script is working", but when i use it during the jumpstart instalaltion, the perl script does not start, without any particular error.
    here is my perl script, if you want to test :
    #!/usr/bin/perl -w^M
    # Set Hostname for Ullink Jumpstart^M
    ^M
    use strict;^M
    ^M
    sub hit_enter {^M
        print "Hit enter to continue\n";^M
        <STDIN>;^M
        print "\033[2J";^M
    }^M
    ^M
    sub get_hostname {^M
        my %towns_list = (^M
            'Paris' => 'PA',^M
            'New-York' => 'NY',^M
        );^M
    ^M
        my %sites_list = (^M
            'Office' => 'OFC',^M
            'Redbus' => 'RED',^M
            'Telehouse' => 'TLH',^M
            'DTC' => 'DTC',^M
            'iAdvantage' => 'IAD',^M
            'Nutley' => 'NUT',^M
            'Level3' => 'LV3',^M
            'Equinix' => 'EQX',^M
            'Tata' => 'TAT',^M
            'Switch-data' => 'SWI',^M
            );^M
    ^M
        my %usage_list = (^M
            'Production' => 'PRD',^M
            'UAT' => 'UAT',^M
            'DMZ' => 'DMZ',^M
        );^M
    ^M
        sub select_list {^M
            my $counter=-1;^M
            my %hash_list = @_;^M
            my @keys = keys %hash_list;^M
    ^M
            # Clear screen^M
            print "\033[2J";^M
            print "In which country this machine is hosted or will be host and will be used ?\n\n";^M
    ^M
            # Get all keys from hash^M
            my $key;
            while ($key = each %hash_list ) {^M
                $counter++;^M
                print "$counter - $key\n";^M
            }^M
    ^M
            print "\nChoose the number corresponding to your choice :\n";^M
            my $choice_number;
            chomp ($choice_number = <STDIN>);^M
    ^M
            # Verify answer^M
            if (($choice_number =~ /\d+/) and ($choice_number <= $counter)) {^M
                # Add choice to chosen hostname^M
                my $chosen=$hash_list{$keys[$choice_number]};^M
                return $chosen;^M
            } else {^M
                print "\nYour answer is not correct, you need to enter a number between 0 and $counter\n";^M
                &hit_enter;^M
                &select_list;^M
            }^M
        }^M
    ^M
        sub srv_number {^M
            print "\033[2J";^M
            print "What is the server number ?\n";^M
            my $server_number;
            chomp ($server_number = <STDIN>);^M
            if ($server_number =~ /\d+/) {^M
                return $server_number;^M
            } else {^M
                print "\nYour answer is not correct, you need to enter a number\n";^M
                &hit_enter;^M
                &srv_number;^M
            }^M
        }^M
    ^M
        my $full_hostname = &select_list(%towns_list).'-';^M
        $full_hostname = $full_hostname.&select_list(%sites_list).'-';^M
        $full_hostname = $full_hostname.'SRV-';^M
        $full_hostname = $full_hostname.&select_list(%usage_list).'-';^M
        $full_hostname = $full_hostname.&srv_number;^M
    ^M
        sub write_hostname2tmp {^M
            open (HOSTNAME, ">/tmp/set_hostname") or warn "Couldn't write $_[0] to temp file : $!\n";^M
                print HOSTNAME "$_[0]\n";^M
            close (HOSTNAME);^M
        }^M
    ^M
        print "\033[2J";^M
        print "Is $full_hostname the correct name for this server ? (y/n)\n";^M
        if (<STDIN> =~ /y|yes/i) {^M
            &write_hostname2tmp($full_hostname);^M
        } else {^M
            print "Would you like to retry (r) or set manually the hostname (s) ? (r/s)\n";^M
            if (<STDIN> =~ /s/i) {^M
                print "Type the full required name and hit enter when finished :\n";^M
                chomp ($full_hostname = <STDIN>);^M
                &write_hostname2tmp;^M
            } else {^M
                &get_hostname;^M
            }^M
        }^M
    }^M
    ^M
    # Start configuration^M
    print "\033[2J";^M
    print "\n########################################################\n";^M
    print "#\t\t\t\t\t\t       #\n";^M
    print "#\t\t\tULLINK\t\t\t       #\n";^M
    print '#  Solaris Environnement Installation for Datacenters  #';^M
    print "\n#\t\t\t\t\t\t       #";^M
    print "\n########################################################\n\n";^M
    print "Before starting installation, you need to enter a set of informations.\n(answer to all questions, you can Ctrl+C to stop now)\n\n";^M
    &hit_enter;^M
    ^M
    &get_hostname;^Mthank for your help
    Edited by: ullink on Jun 25, 2009 6:05 AM

    Hi Manju,
    You can try the following command and check if any helps:
    Get-Exchangeserver |where-object{$_.AdminDisplayVersion -like "Version 15*"} |Get-MailboxStatistics | Ft -auto -wrap DisplayName,database,servername,*size*,*time*
    Best regards,
    Niko Cheng
    TechNet Community Support

  • Runtime.exec("Perl Script writing and reading on I/O"), handling Streams

    Hi all !!
    In a first place : sorry for my english if it's not really understandable but I try to do as good as possible !
    I'm writing a GUI with Swing that will allow (in one of my multiple tables) the user to run a Perl Script.
    This Perl Script ask the user to choose a Folder ... then read all the files in this folder and for each file (xml File), extract the datas and put them in a database. But when a file that has to be inserted in the database contains this line : <Template_Used name="ST1.mtt"> and if the Template table in my database doesn't have the "ST1.mtt" stored ... the Perl Script ask to the user to give him the path of the file "ST1.mtt" so that the script can put the "ST1.mtt template" datas in the database.
    This script runs well when it is from a windows console.
    But I need a graphic interface !!!
    So I created a JButton "Process a folder".
    When the button is pressed, a JFileChooser appears and ask the user which Folder has to be processed.
    Then a Process is created with the command : ("cmd.exe /C \"C:\\Program Files\\Fluke\\Ansur\\ProcessFolder.bat\").
    The BatFile :
    {code}cd C:\Documents and Settings\tsd\Desktop\Gael-Project\Project_Files
    perl Process.pl
    exit{code}
    At this moment everything is working well.
    But my Process.pl (which is 300 lines long ... and that you don't even want to hear about), ask in a first time the Path of the folder to process and sometimes ask the path to a file (a template file).
    So I need to read and wirte on the STDIN/STDOUT during the exec of the Process.
    In order to handle this I created two different threads : one reading the Process.getInputStream with a BufferedReader and one other writing on the Process.getOutputStream with a PrintWrinter.
    What I need to do is :
    When I read a line from the InputStream saying "I need the path of the ST1.mtt file", I should run a JFileChooser ... the user find the file in the computer ... and I write in the OutputStream the path of the file, so that my Perl Script doesn't have un Unitialised value on <STDIN> and can continue to process !!
    I'm pretty sure it's possible ... because at the moment I just used a trick :
    When the user push the "process a folder" button, I write the paths in the OutputStream before than the script needs it and it works !
    But I need to write in the OutputStream only when it is time !!!
    Any idea ??
    Here are some parts of my code :
    {code}
    String filename = File.separator+"tmp";
              JFileChooser fc = new JFileChooser(new File(filename));
              fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY );
              // Show open dialog; this method does not return until the dialog is closed
         fc.showOpenDialog(null);
         Folder = fc.getSelectedFile();
              new GoodExec(cmd);
    {code}
    {code}
    public class GoodExec {
         public static Process proc;
         public static StreamGobbler errorGobbler;
         public static StreamGobbler inputGobbler;
         public static StreamGobbler outputGobbler;
         public GoodExec(String cmd)
         try
                   Runtime rt = Runtime.getRuntime();
              proc = rt.exec(cmd);
         // any error message?
         errorGobbler = new
         StreamGobbler(proc.getErrorStream(), "ERROR");
         // any input?
         inputGobbler = new
         StreamGobbler(proc.getInputStream(), "INPUT");
         // any output?
              outputGobbler = new
              StreamGobbler(proc.getOutputStream(), "OUTPUT");
         // kick them off
         errorGobbler.start();
         inputGobbler.start();
         outputGobbler.start();
         // any error???
         int exitVal = proc.waitFor();
         System.out.println("ExitValue: " + exitVal);
         } catch (Throwable t)
         t.printStackTrace();
    {code}
    {code}
    public class StreamGobbler implements Runnable
    InputStream is;
    OutputStream os;
    String type;
    Thread thread;
    public static String chaine;
    StreamGobbler(InputStream is, String type)
    this.is = is;
    this.os=null;
    this.type = type;
    StreamGobbler(OutputStream os, String type)
    this.os = os;
    this.is=null;
    this.type = type;
    public void start () {
         thread = new Thread(this);
         thread.start ();
    public void run()
    try
    if (is == null){
         PrintWriter toProgram = new PrintWriter(os);
         File FolderToProcess = ProcessFolder.Folder;
    String Folder = FolderToProcess.getPath();
    toProgram.write(Folder);
    toProgram.close();
    else {
         if (os == null){
         InputStreamReader isr = new InputStreamReader(is);
    BufferedReader br = new BufferedReader(isr);
    String line=null;
    String comp = "Please enter the exact path of the directory that contains the files you want to process.";
    while ( (line = br.readLine()) != null){
         if (type.equals("INPUT")){
              chaine+=line+"\n";
         if (line.equals(comp)) {
              System.out.println("give directory");RUN A JFILECHOOSER AND GIVE THE DIRECTORY TO THE OUTPUTSTREAM
    System.out.println(type + ">" + line);
    is.close ();
    catch (IOException ioe){
         ioe.printStackTrace();
    {code}
    And here is an example of a simple perl script that could be used (it s a simple one !!) :
    {code}
    #!/usr/bin/perl -w
    use strict;
    print "Please enter the exact path of the directory that contains the files you want to process.\n";
    my $dir= <STDIN>;
    chomp ($dir);
    print "titallala $dir";
    if (the template of the file is not in the database){
    print "Please give me the template so that I can put it in the database";
    $dir= <STDIN>;
    chomp ($dir);
    {code}
    Thank you for your help ... if it's possible to help me !!
    Gael

    BalusC -- The line that gives me my NullPointerException is when I call the "DisplayProduct()" method. Its a dumb question, but with NetBeans how do I find out which reference could be null? I'm not very familiar with how NetBeans works with finding out how to debug. Any help you can give me would be greatly appreciated.The IDE is com-plete-ly irrelevant. It's all about the source code.
    Do you understand anyway when and why a NullPointerException is been thrown? It is a subclass of RuntimeException and those kind of exceptions are very trival and generally indicate an design/logic/thinking fault in your code.
    SomeObject someObject = null; // The someObject reference is null.
    someObject.doSomething(); // Invoking a reference which is null would throw NPE.

  • How to call a perl script from an apple script

    Hi All,
    How to Call a perl Script from an apple script.
    Pls Give Your comments.
    Thanx & Regards,
    Esther

    Applescript to call a perl script named "/tmp/x.pl" passing an argument "world"
    do shell script "/usr/bin/perl /tmp/x.pl world"
    or if the script is given the executable atttribute (chmod +x /tmp/x.pl),
    do shell script "/tmp/x.pl world"
    Perl script "/tmp/x.pl" that prints a string using a passed argument
    #!/usr/bin/perl
    print "Hello $ARGV[$1]\n";

Maybe you are looking for