how to pipe output of here-document!!

anybody can help, plz:

I want to pass the output of "ls" to "grep":

ftp -n host <<!
USER user passwd
ls
bye
! | grep file

exit 0

It does not work!!

Any idea??

Sami

try this, not tested

ftp -n host <<!  >>file

Like this...

#! /usr/bin/ksh
awk 'BEGIN {srand()} {printf "%08.0f %s\n", rand()*99999999., $0}' << EOF | sort -n | awk 'NR==1 { print substr($0,10)}'
line 1
line 2
line 3
line 4
line 5
line 6
line 7
line 8
line 9
line 10
line 11
line 12
line 13
line 14
line 15
EOF
exit 0
$ ./heredoc
line 10
$ ./heredoc
line 11
$ ./heredoc
line 9
$ ./heredoc
line 7
$ ./heredoc
line 14
$ ./heredoc
line 1
$ ./heredoc
line 8
$

it does NOT work!! I mean something like:

#!/bin/sh

ftp -n $1 <<!
USER $2 $3
ls
bye
! | grep $4

exit 0

Dear

You can grep the output of ls by using following command

ls -ltr | grep rahul

In above command you are listing all the things in current directory but greping rahul in that directory so output for this command will be grepe rahul.

Dear

I want do the following (in the same shell procedure):

1) list the content of the remote ftp host
2) pipe the listing to grep

any idea???

This should work:

ftp -n $1 <<! | grep $4
USER $2 $3
ls
bye
!

robotronic, it works fine!!!

Thank you