The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
pipe output to script as command line argument IMTheNachoMan UNIX for Dummies Questions & Answers 3 04-26-2008 12:59 PM
How to conver a unix output file to Microsoft word document divyacl UNIX for Dummies Questions & Answers 1 02-02-2007 05:11 AM
output string message to pipe princelinux High Level Programming 3 08-18-2006 02:09 AM
The here document << rahulrathod Shell Programming and Scripting 6 01-23-2006 12:05 AM
Help on find a document merlin UNIX for Dummies Questions & Answers 1 02-14-2002 08:42 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-16-2008
sami98 sami98 is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 10
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
  #2 (permalink)  
Old 02-16-2008
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,512
try this, not tested
Code:
ftp -n host <<!  >>file
  #3 (permalink)  
Old 02-16-2008
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
Like this...
Code:
#! /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
$
  #4 (permalink)  
Old 02-17-2008
sami98 sami98 is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 10
it does NOT work!! I mean something like:

#!/bin/sh

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

exit 0
  #5 (permalink)  
Old 02-17-2008
rahul_bakde rahul_bakde is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 4
Smile Ls to grep

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.
  #6 (permalink)  
Old 02-17-2008
sami98 sami98 is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 10
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???
  #7 (permalink)  
Old 02-17-2008
robotronic's Avatar
robotronic robotronic is offline Forum Advisor  
Can I play with madness?
  
 

Join Date: Apr 2002
Location: Italy
Posts: 370
This should work:

Code:
ftp -n $1 <<! | grep $4
USER $2 $3
ls
bye
!
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:01 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0