Hello Monks,
I am connecting to the remote server using Telnet module and want to grep the content of file in particular directory.But it is giving an error,See the code below,
$checkfile = "back-20.bak"; $direcory ="/sapp/backup"; $contcheck = "Backup taken for this file"; $telnet->cmd("opendir dhandle,$directory"); @dots = $telnet->cmd("grep { /^$checkfile/ } readdir(dhandle)"); print"Files=> @dots\n"; foreach $filename (@dots) { chomp($filename); @filecont = $telnet->cmd("grep -i $contcheck"); foreach $line (@filecont) { if($line =~ /$contcheck/){ $status = 'FAIL'; }else{ $status ='PASS'; } } }
For the above code,if back-20.bak file is availabe in the remote machine in the location /sapp/backup and if the content of the file is having data like "Backup taken for this file" I have to assign status as pass or if the content is not available in that file status is assigned to fail.
Monks let me know where I am doing wrong?
I am getting the output as,
Files=> ksh: syntax error: `(' unexpected
Thanks.

In reply to Remote server file access issue by qsl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.