FTP stores unwanted chars to output file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting FTP stores unwanted chars to output file
# 1  
Old 08-13-2010
FTP stores unwanted chars to output file

I want to only store date of all files. However, the below script also store
unwanted FTP related lines to output file.

Could someone tell me how to ignore them (see output first 6 lines)?

Thanks

Code:
    #Defining variables and assigning values
USR='admin'
PASSWD='abc'
HT='xyz.aaa.com'
FILE='S*.pdf
DIRNAME='/doc'
 
function LsFiles(){
ftp -n -i -v $HT <<end_ftp
user $USR $PASSWD
cd $DIRNAME
ls "-lrt *.pdf"
bye
end_ftp
}
 
LsFiles | awk '{ printf $6 " " $7"\n"}' >> output.txt)


output.txt file:
---------------

and PASS.
and PASS.


listing.
Jun 07
Jun 07
Jun 07
Jun 07
Jun 07
Jun 07
Jun 07
# 2  
Old 08-13-2010
FTP is not a shell, you shouldn't use it to script things that don't involve transferring files. You should be using ssh or the like... ssh will also let you do this more securely, by using secure keys instead of hardcoded human-readable text passwords.
# 3  
Old 08-16-2010
Thanks for the reply.

I need to use FTP because files are setting on remote server.

Let me give you more details about my problem.

I have backup_server and application_server.

backup_server has directory aaa. I need to check from application server
that is there any new files created today in the aaa dirctory. if yes, all files were created today or partial files?.

Based on all or partial, I have perform some actions from application server, before transferring files from backup_server to applicaiton_server.

I am not expert in scripting. Please suggest me the way.

Thanks
Dip

---------- Post updated at 07:27 PM ---------- Previous update was at 02:52 PM ----------

Code:
#Defining variables and assigning values
USR='admin'
PASSWD='test'
HT='test.linux.ca'
FILE='S*.pdf'
DIRNAME='/docs'
 
echo $HT
ftp -n -i -v $HT <<end_ftp
user $USR $PASSWD
cd $DIRNAME
CT=ls -RF | sed -e '/^$/d' -e '/.*[/@:=|>]$/d' |wc -l
echo $CT
bye
end_ftp

It says invalid command. Can some one write. How to write the code
to count files on remote server.

Thanks
dip
# 4  
Old 08-17-2010
A few pointers:

1) Lose the "-v" switch to "ftp". It turns on verbose mode which where a lot of your excess messages are coming from.

2) The syntax of your function is incorrect.

3) There is a spurious trailing parenthesis at the end of the last line.

4) The FILES variable is never referenced.

Code:
#Defining variables and assigning values
USR='admin'
PASSWD='abc'
HT='xyz.aaa.com'
FILE='S*.pdf
DIRNAME='/doc'
 
LsFiles()
{
ftp -n -i $HT <<end_ftp
user $USR $PASSWD
cd $DIRNAME
ls "-lrt *.pdf"
bye
end_ftp
}
 
LsFiles | awk '{ printf $6 " " $7"\n"}' >> output.txt

This User Gave Thanks to methyl For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Shell script to split data with a delimiter having chars and special chars

Hi Team, I have a file a1.txt with data as follows. dfjakjf...asdfkasj</EnableQuotedIDs><SQL><SelectStatement modified='1' type='string'><! The delimiter string: <SelectStatement modified='1' type='string'><! dlm="<SelectStatement modified='1' type='string'><! The above command is... (7 Replies)
Discussion started by: kmanivan82
7 Replies

2. Shell Programming and Scripting

Execute python file, FTP output to another server

Greetings all, We are implementing a new tool called URLwatch which is a python utility. Here are the requirements. 1) Run every 10 seconds 2) Execute the python script 3) Output file gets generated, FTP it to a differernt server I gave no idea how to do this and management needs a demo... (3 Replies)
Discussion started by: jeffs42885
3 Replies

3. UNIX for Advanced & Expert Users

Not logging ftp connections in /var/adm/wtmpx file (in last command output)

Hi all, I have F5 load balancer on my system and checking service status by opening an ftp session in every 30 seconds. These ftp sessions are being logged in /var/adm/wtmpx and filling up the file. when i run the last command most of the output is this ftp session. I was wondering if there is a... (1 Reply)
Discussion started by: cepxat
1 Replies

4. Red Hat

How to find file which stores IP address

Hi all, I am new to this forum and this is my first question :). Using Red hat Linux.I tried to find file which stores IP address based on different helps given in this forum but did not get success. Here is the system details: -bash-3.2$ lsb_release -a LSB Version: ... (2 Replies)
Discussion started by: Barkha
2 Replies

5. Shell Programming and Scripting

Output trimming after 80 chars

Hi All, I have a small issue with my shell script, I call a sql query from it and the output of the query is a Varchar2 data of approx 100 chars. But while printing the data on the console, only 80 chars are printed. The same thing happens even while redirecting the output to a file, only 80... (6 Replies)
Discussion started by: vinayakawasthi
6 Replies

6. Shell Programming and Scripting

find 4 chars on 2nd line, 44 chars over

I know this should be simple, but I've been manning sed awk grep and find and am stupidly stumped :( I'm trying to use sed (or awk, find, etc) to find 4 characters on the second line of a file.txt 44-47 characters in. I can find lots of sed things for lines, but not characters. (4 Replies)
Discussion started by: unclecameron
4 Replies

7. Linux

Output to 1 file from two files in FTP

I am currently in FTP. I want to transfer two files and need the out put in One file. Can you help me.... For eg: if i am doing mget from 1 server to other. (1 Reply)
Discussion started by: manish.s
1 Replies

8. UNIX for Advanced & Expert Users

Problem in FTP of file with chinese chars

Hi, I have a file in my PC with Chinese (PRC) characters. When I transfer that file into my AIX5.3 server through FTP, I get junk characters instead of Chinese chars. Last week I copied the content from my notepad and pasted in vi editor. The Chinese characters were correct, but when I try now,... (4 Replies)
Discussion started by: carthyc
4 Replies

9. UNIX for Dummies Questions & Answers

Diff output, unwanted characters

I've got a diff command running in a shell script that writes the ouput to a new file. In the new file there is a ">" at the beginning of each line. The output file is going to be used by another program and that character makes the file useless. What I'm getting in the new file: > 2007-09-27... (5 Replies)
Discussion started by: scanner248
5 Replies

10. Shell Programming and Scripting

How to convert C source from 8bit chars to 16bit chars?

I was using the following bash command inside the emacs compile command to search C++ source code: grep -inr --include='*.h' --include='*.cpp' '"' * | sed "/include/d" | sed "/_T/d" | sed '/^ *\/\//d' | sed '/extern/d' Emacs will then position me in the correct file and at the correct line... (0 Replies)
Discussion started by: siegfried
0 Replies
Login or Register to Ask a Question