in reply to Re: FR Config Sanity Checking
in thread FR Config Sanity Checking

Excellent, time to brush up on commandline perl! The problem would be exporting the information out of exec or system. How would I go about doing that, with > or |?

system(/usr/bin/ssh HOST_ABC \"perl "open(FILE,\">>file\"; stat(FILE)[ +9] > $local_var"); print $local_var;

???
amt.

perlcheat

Replies are listed 'Best First'.
Re^3: FR Config Sanity Checking
by hsinclai (Deacon) on Oct 05, 2004 at 00:14 UTC
    I think what you need, is best done from your originating server, by sending a command that will execute remotely, to check the last modification time of $remotefile

    #!/usr/bin/perl -w use strict; my $remotefile = '/tmp/yourfile.conf'; my $remotestat = qx! ssh -2 -p 12345 172.16.16.82 'perl -e "print ((stat(qq~$remotef +ile~))[9])" ' !; print "\n$remotestat \n"; print "\n", scalar localtime($remotestat), "\n\n";
    If your ssh setup is working properly, this should return the value you need from the remote server. You might then keep a comparison table locally so if you determine the file was edited by someone other than your script you could then act accordingly..

    I would just like to add though, that planning the whole thing architecturally - diagram it! - before writing the app will ultimately save you time.. then the code writing will become the final task. It will also be easier to document, and explain to users, management, etc

    It also seems to me that to make your app a little closer to bulletproof you should consider keeping versioned backups of the remote files -- having multiple users jumping in to edit a single file at will with no change control or revisioning is kinda crazy.

      hsinclai, baby steps...haha. I needed a quick and dirty to give to my boss today, so the robust stuff will come during the rest of the week.

      You've been a great help on this project, many thanks!
      amt.

      perlcheat