Sponsored Content
Top Forums Shell Programming and Scripting Perl: Opening a filehandle but not getting anything back from it Post 302223936 by Smiling Dragon on Monday 11th of August 2008 07:26:15 PM
Old 08-11-2008
Interesting news on this:
Once again, I rewrote it (feeling sure it had to be a typo someplace as such a similar function elsewhere was working) and it's now working!
The working code:
Code:
sub getndstatus {
        my %results;
        my @nds=@{$_[0]};
        my @sysmanhandles;
        foreach my $check("EnableND","StartND") {
                foreach my $nd(@nds) {
                        my $sysman="$config{'su'} - $config{'user'} -c \'$config{'sysman'} ${check}Check -m $nd\'";
                        local *SYSMAN;
                        open(SYSMAN, "$sysman|");
                        push(@sysmanhandles, *SYSMAN);
                }
        }
        foreach my $check("EnableND","StartND") {
                foreach my $nd(@nds) {
                        my $sysmanhandle=shift @sysmanhandles;
                        while(<$sysmanhandle>) {
                                if (/^<([^>]*)> <([^>]*)> (.*)$/) {
                                        $ip=$1;
                                        $result=$2;
                                        $note=$3;
                                        $results{$nd}{$check}="${result}:${note}";
                                }
                        }
                        close($sysmanhandle);
                }
        }
        %results;
}

It turned out the escaped single quotes in the command where required, otherwise su took the remaining parameters to sysman and assumed they where for itself instead.

I can't actually see any differences in this version but I made a special effort to write it 'blind' - that is, I avoided looking at the old code when I wrote this.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Opening Perl

I have gone to /usr/bin/ and click on perl but notting happens.also notting happens when i click on c/c++ or any other program whats wrong ? (2 Replies)
Discussion started by: perleo
2 Replies

2. Shell Programming and Scripting

perl: howto print to screen & filehandle

Hello, I need to print messages both to screen and to file handle in perl , like tee does in unix . Any suggestions ? Thanks (2 Replies)
Discussion started by: Alalush
2 Replies

3. Shell Programming and Scripting

Opening Files and checking contents in Perl

Hi All, I need some expert help in performing the following in Perl. I have a code below but it doesn;t seem to work. Can any expert give me some advice? Below are the requirements 1) Open numerous files assigned to an array @FILES. Note that the files are always named with the term... (7 Replies)
Discussion started by: Raynon
7 Replies

4. Shell Programming and Scripting

Opening Mulitple files using For loop in Perl

Hi All, I have a total of ten file to open in the Perl script and i am using a for loop to open each file and capture some strings inside each file. Unfortunately, i encounter the below syntax error. I think there should be something wrong with this term reports_${counting}_${_}.txt but i do... (4 Replies)
Discussion started by: Raynon
4 Replies

5. Shell Programming and Scripting

How to call a shell script from a perl module which uses Filehandle to login

Hi Guru's, Pardon me for the breach of rules..... I have very little knowledge about Shell Programming and Scripting hope you guys help me out of this troble I have very little time hence could not find the right way to direct my queries. coming to the problem I need to call a... (2 Replies)
Discussion started by: saikrishna_tung
2 Replies

6. Shell Programming and Scripting

Perl-opening a file then copying files

Good morning guys!! Im still practicing with Perl and now Im trying to open a file, and copy its contents to another file. Them I want to remeove the information out of the orginal file after it is copied over. The flow should be messages-->messages1-->messages2. Kind of like a log... (1 Reply)
Discussion started by: bigben1220
1 Replies

7. Programming

Error:readline() on closed filehandle Perl

Hi, i have run the below perl code and i am getting an error Error:readline() on closed filehandle OR at run.pl line 31. CODE: =========================================== open OR,$ARGV; while (<OR>) { # find the batch date next if length $_ < 3; # BLANK LINE # last if $. > 120; #... (3 Replies)
Discussion started by: pspriyanka
3 Replies

8. UNIX for Dummies Questions & Answers

Opening a file in perl

Hi I need to open a file if a condition(for example a if a regular expression) is met. How do i do this ? open (file) if (some regex)..... (3 Replies)
Discussion started by: manutd
3 Replies

9. Shell Programming and Scripting

perl FileHandle Closure during after unlock

Hi we have one function which is used to append data the file in exclusive lock mode in aperl script. This script is executed by multiple threads at the same time. accessing the same file.this script runs throught the day. sometimes the file2.txt size is getting reduced. for eg from 10 M... (1 Reply)
Discussion started by: Shahul
1 Replies

10. Shell Programming and Scripting

Printing a message in file without opening it in perl

Hello friends, i have a perl script as below ... for (0 ..$#values) { ##want to print some message here in Report.txt file print `find /abc/xyz/pqr/$values" -type f -ls` >> Report.txt } I am able to get output of print `find /abc/xyz/pqr/$values" -type f -ls` >> Report.txt in... (2 Replies)
Discussion started by: harpal singh
2 Replies
evmviewer(8)						      System Manager's Manual						      evmviewer(8)

NAME
evmviewer - View events SYNOPSIS
Opening the viewer as a process: /usr/share/sysman/menu/tasks/evmviewer/evmviewer [-ui ui_mode] [-display display_name] [-filter filter_expr] [-host host- name[:port_no]]... [-input logfile] Opening the viewer using the SysMan Menu: /usr/sbin/sysman -menu "View events" [-ui ui_mode] [-display display_name] [-filter filter_expr] [-host hostname[:port_no]]... [-input logfile] Opening the viewer using a SysMan Menu accelerator: /usr/sbin/sysman [-accel] event_viewer [-ui ui_mode] [-display display_name] [-filter filter_expr] [-host hostname[:port_no]]... [-input logfile] OPTIONS
Specifies the user interface to be invoked. The choices are: Specifies command line interface. Specifies graphical user interface. Speci- fies Java interface. Specifies the display screen on which evmviewer displays its window. If the display flag is not specified, the dis- play screen specified by the DISPLAY environment variable is used. The display_name variable has the format hostname:number. The default is :0. For more information, see the X(1) reference page. Initializes the display only with events which match the filter_expr. See the EvmFilter(5) reference page for the syntax of filter_expr. Attempts to connect to the EVM daemon on the host hostname, rather than to the local daemon. This option may be repeated to obtain events from several hosts. If the name of the local host is included, a remote connection to the local daemon is made. If specified, use port_no for TCP communication with remote clients. If not specified, use the evm port number found in /etc/ser- vices. If not specified, and no entry is found in /etc/services, use the reserved value of 619. Retrieve events from the file log- file rather than from the event logs. When operating in the gui mode, the evmviewer application also supports all of the standard flags described in the X(1) reference page. OPERANDS
None DESCRIPTION
The evmviewer is a SysMan Menu application that lets you retrieve events and display them. Events may be retrieved from the log files on one or more hosts, or from a file of events stored on your local system. The evmviewer application can be invoked from the SysMan menu or from the command line. To open the evmviewer from the Sysman Menu, do the following: Open the SysMan Menu application. Select Monitoring and Tuning. Select View Events. To open the evmviewer from the command line, use one of the forms shown in the SYNOPSIS section. Online help is available for the evmviewer application. To get help, select Help from any dialog box. ENVIRONMENT VARIABLES
The following environment variables affect the execution of evmviewer: Specifies the display screen on which evmviewer displays its window. This variable has the format hostname:number. The default is :0. For more information, see the X(1) reference page. Specifies the user interface to be invoked. The choices are: Specifies command line interface. Specifies graphical user interface. RESTRICTIONS
None EXIT VALUES
None FILES
Definition of the sockets and protocols used for Internet services Executable file SEE ALSO
Commands: evmget(1), evmshow(1), evmsort(1), sysman(8), X(1) Files: services(4) Event Management: EVM(5) EVM Events: EvmEvent(5) Event Filter: EvmFilter(5) delim off evmviewer(8)
All times are GMT -4. The time now is 04:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy