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
xx=`date +"%a %b %d"`;rsh xxx grep "^$XX" zzz ? Browser_ice AIX 2 06-13-2009 09:39 AM
Development Releases: Linux Mint 4.0 Beta "Fluxbox", 4.0 Alpha "Debian" iBot UNIX and Linux RSS News 0 01-04-2008 03:00 PM
Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" Lokesha UNIX for Dummies Questions & Answers 4 12-20-2007 01:52 AM
grep to find content in between curly braces, "{" and "}," keshav_rk Shell Programming and Scripting 4 08-09-2007 11:14 PM
No utpmx entry: you must exec "login" from lowest level "shell" peterpan UNIX for Dummies Questions & Answers 0 01-18-2006 04:15 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-20-2009
Lenora2009 Lenora2009 is offline
Registered User
  
 

Join Date: Jul 2009
Location: Seattle, WA
Posts: 31
grep "226 Transfer complete" | wc -l

echo $ftp_ctr returns '0' instead of '1'. Please help

Code:
331 Enter password
230 User logged in
200 Transfer mode set to BINARY
local: file1 remote: file2
227 Entering Passive Mode (xxxxxxxx).
125 Uploading in BINARY file xxx 
226 Transfer completed
24453780 bytes sent in 67 seconds (3.6e+02 Kbytes/s)
221 bye
0
Code:
# Upload to ftp 
################################################### 
ftp -v -n $HOST <<EOF
quote user $FTPUSER
quote pass $PASSWD
cd "/name1/name2"
bin
put $FILEIN $FILEOUT
EOF
 
# Check the ftp status and file
# ## wc -l tells the number of lines (accounts)
################################################### 
ftp_ctr=`ftp<<EOF| grep "226 Transfer complete" | wc -l
EOF
`
echo $ftp_ctr

Last edited by vgersh99; 07-20-2009 at 05:58 PM.. Reason: code tags, PLEASE!
  #2 (permalink)  
Old 07-20-2009
benefactr benefactr is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 71
I'm unsure what you are doing in your wc statement with the ftp command, but I always redirect the ftp to a log and then grep from that log.



Code:
ftp -pnv > /tmp/ftp.log <<-EOF
...
EOF
CHECKERR=`cat /tmp/ftp.log | grep 226 | wc -l`
  #3 (permalink)  
Old 07-20-2009
RiSk RiSk is offline
Registered User
  
 

Join Date: May 2008
Posts: 20
Quote:
Originally Posted by benefactr View Post
I'm unsure what you are doing in your wc statement with the ftp command, but I always redirect the ftp to a log and then grep from that log.



Code:
ftp -pnv > /tmp/ftp.log <<-EOF
...
EOF
CHECKERR=`cat /tmp/ftp.log | grep 226 | wc -l`
use grep -c 226, oneless pipe
  #4 (permalink)  
Old 07-20-2009
Lenora2009 Lenora2009 is offline
Registered User
  
 

Join Date: Jul 2009
Location: Seattle, WA
Posts: 31
cannot use ftp -pvn


here is the message :
Code:
ftp: p: unknown option
Usage: ftp [-v] [-d] [-i] [-n] [-g] [-k realm] [-f] [-x] [-u] [-t] [host]

Last edited by vgersh99; 07-20-2009 at 05:59 PM.. Reason: code tags, PLEASE!
  #5 (permalink)  
Old 07-20-2009
benefactr benefactr is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 71
Quote:
Originally Posted by Lenora2009 View Post
cannot use ftp -pvn


here is the message :
Code:
ftp: p: unknown option
Usage: ftp [-v] [-d] [-i] [-n] [-g] [-k realm] [-f] [-x] [-u] [-t] [host]
Use your orginal ftp statement, mine was just a example, but just add the redirect before the <<EOF in your just like I did in mine.
  #6 (permalink)  
Old 07-20-2009
gandarez gandarez is offline
Registered User
  
 

Join Date: Sep 2008
Location: São Paulo/Brazil
Posts: 16
Quote:
Originally Posted by benefactr View Post
I'm unsure what you are doing in your wc statement with the ftp command, but I always redirect the ftp to a log and then grep from that log.



Code:
ftp -pnv > /tmp/ftp.log <<-EOF
...
EOF
CHECKERR=`cat /tmp/ftp.log | grep 226 | wc -l`

CHECKERR=`grep -c 226 /tmp/ftp.log`

This works ??
  #7 (permalink)  
Old 07-20-2009
vgersh99's Avatar
vgersh99 vgersh99 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,122
To keep the forums high quality for all users, please take the time to format your posts correctly.

First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags [code] and [/code] by hand.)

Second, avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.

Third, be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

Thank You.

The UNIX and Linux Forums
Reply

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 03:28 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