Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with STDIN

Status
Not open for further replies.

pluscarden

Programmer
Jan 26, 2004
26
0
0
GB
I am running Legato NW on a Windows 2000 server and have created a customised server notification that will automatically run a perl script on Savegroup Completion (alert or notice). This is what I have got in my action field :

D:\perl\bin\perl.exe C:\backup_status.pl

My perl program uses a standard loop kinda thing :

Example

while (<STDIN>) {
do stuff with $_;
}

But the problem I have is that nothing appears to be getting passed in!

I always assumed that NW automatically made the contents of the Savegroup Completion Notification available to your program via <STDIN>. Does anybody know what I need to do to get this to work?

Incidentally, I had the same problem on UNIX but managed to resolve it by using awk within my script (rather than a while loop). But I obviously don't have this luxury on Windows!

Any help/advice would be much appreciated.
 
Use the nsrlog command to write the logged output through a file, then pipe it through your script.
 
Hi, you will have to forgive me but I am quite new to Legato NW and my knowledge of Windows programming syntax is not so hot either!

Please could you give me an example of how I would achieve this.

I am assuming you mean I should have something like this in my action field :

nsrlog -f "myfile";type myfile | myperlscript.pl

but I am not even sure if this is allowed. And I doubt my syntax is correct!
 
Hi...

I think I have seen this link before but it didn't seem to help :-(

You will notice that the article does state the following (when discussing the 'Action' parameter) :

'Note: When the "Action" program or script is invoked, the contents of the message are passed in STDIN.'

My understanding of this statement is that I should be able to have something like this in my action field :

D:\perl\bin\perl.exe C:\backup_status.pl

and Legato NW will automatically pass the entire contents of the Savegroup Completion Notification to my script via standard input. Consequently, my script should then be able to process the contents of the Savegroup Completion Notification on a line by line basis with the following (which is the standard perl syntax for reading from standard input) :

while (<STDIN>) {
#do stuff with $_ here
}

But Legato NW doesn't seem to be passing anything in at all to my script in this context. Though it obviously works with commands like nsrlog, etc. So why doesn't it work in this situation...even though the documentation says it will?

Basically, I just need to know what I have to put in the action field to make NW pipe the contents of the Savegroup Completion Notification to my script (or what I need to put in my script to get at this information).

Cheers





 
Looks like there was a problem with my perl script after all!

Basically, my script extracts the backup group name from the header record and uses this to formulate a filename to which I then save the report.

To identify the header record I was searching for the text "Networker Savegroup" instead of "NetWorker Savegroup". Consequently, my script couldn't find the header record and wasn't doing anything!

I put in the uppercase "W" and it now works fine.

Thanks for all your help anyway.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top