how to read remote file

From: rashmi (nsrashmi_at_gmail.com)
Date: 03/30/05


Date: Wed, 30 Mar 2005 01:59:13 -0500

1.login to the other system
2.then open file
3.search for a string
4.return the search results
to the above set of tasks i tried using
 spawn ssh -l "root" "mysystem"
 expect spawn_id
 expect "Password:"
 send "90909\r"
 expect "*#"

 set file [ open "/tmp/hostname.org" "r" ]
        while { [gets $file buf] != -1 } {
         puts $buf

          if { [ string match "*string*" $buf ] } {
                stty -echo
                send "echo"

          }

        }
but i found this does'nt work can instead i'm using traditional cat ,grep
,echo $? ,expect 0/!=0
method.
Does any one have the better way?



Relevant Pages

  • Re: List files containing a string..
    ... Er, the question was about files containing a string, not about file ... got were responses like man grep, ... What is not readily apparent in the xargs man page is that it ... that is the standard one on FreeBSD has a -r/-R option and even ...
    (comp.unix.bsd.freebsd.misc)
  • Looking for text inside files does not work at all
    ... for an ascii text string in a file. ... Hex-editing the file reveals that there is a string called "reloc" right ... So if text search (aka grep) worked, this should work too shouldn't it? ... That's how it worked in Windows 2000. ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: modifying files using script
    ... specific string with another one. ... This script works well for one file but exits after that. ... so I used fgrep in the example (grep -F may be preferable or required ... as string by fgrep and RE by $editor, ...
    (comp.unix.shell)
  • Re: grep a string
    ... > I am trying a find all occurences of a SUBSTR in string ... > will -b option for grep be useful. ... SUBSTR or not. ... > perl script to find all occurences of SUBSTR.. ...
    (comp.unix.shell)
  • Looking for ascii text inside files doesnt work at all
    ... for an ascii text string in a file. ... Hex-editing the file reveals that there is a string called "reloc" right at the beginning of the file. ... So if text search (aka grep) worked, this should work too shouldn't it? ... I change the term in the _middle_ input field to 'i.cpl'. ...
    (microsoft.public.windowsxp.help_and_support)