Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Understanding FTP connection code Post 302382157 by jim mcnamara on Tuesday 22nd of December 2009 10:56:35 AM
Old 12-22-2009
This has an error note the change in red:
Code:
ftp -v -n 10.xy.pq.rs << cmd
user xyz_user #$@%@$
cd /u03/app/informatica/7.1.4/server/SrcFiles
cmd

Both the here document (the code fixed) and the file input are both being read as stdin to the ftp process. Not different there. The file version merely has extra overhead:
opening & closing $execdir/ftp_CostPriceFIPR.log several times. It is also going to be harder to maintain longterm. Unless there is someoverriding reason to use a file, consider the here doc.

another option:
use echo which eliminates the $execdir/ftp_CostPriceFIPR.log as the middleman:

Code:
echo "
  user plpl xxxxxx
  cd somewhere
  get somefile
  put anotherfile
  exit
 " ftp -v -n 10.xy.pq.rs > ftplog

Life is full of choices when write unix code....

Last edited by jim mcnamara; 12-22-2009 at 12:09 PM..
 

10 More Discussions You Might Find Interesting

1. Cybersecurity

FTP Connection

I just started a new job and inherited a Fedora core 3 server. I wanted to open the ftp ports and I wanted to verify this code before I mess things up. From my reading the two lines below should allow ftp access can anyone confirm my attempt. iptables -A INPUT -p tcp - sport 21 -m state - state... (0 Replies)
Discussion started by: mungaz
0 Replies

2. Solaris

ftp connection problem

Hi all, i am not able to connect the ftp through userA. Can you please tell me what are the possible ways to troubleshoot this issue? Regards krishna (2 Replies)
Discussion started by: krishna176
2 Replies

3. SCO

ftp connection

I have problem with ftp connection on SCO UNIX 5.0.7, it is work slowly. How I can make accelerate. (6 Replies)
Discussion started by: draganmi
6 Replies

4. UNIX for Dummies Questions & Answers

ftp - Connection close

Hi Can someone help me what is the problem, when i try to login via ftp, though i entered the correct password, i got an error message Connection refused. please help. thanks (3 Replies)
Discussion started by: kaibiganmi
3 Replies

5. Solaris

I want to hard code username and password for an FTP connection

Hi all i want to do FTP via running a shell script and i want to hard code username and password for that particular server.. by writing it in a file can u help me in this regard.. Thank u Naree (2 Replies)
Discussion started by: naree
2 Replies

6. UNIX for Dummies Questions & Answers

FTP Connection

Hi, Anyone encounter whereby when you FTP from an Unix server (Solaris 8) to another server (Window Server 2003), you tend to wait a long while when you do a "ls" and you get a timeout after that. However, when you FTP again and do a "ls", the result of "ls" shown immediately. All connection are... (5 Replies)
Discussion started by: ahlude
5 Replies

7. Shell Programming and Scripting

FTP connection problem

I am getting the error in this command when i am pitting it in shell script ftp -nvi jcmpcor1.abc.com >/work/test98.dat << EOD error:- invalid command. but when i am writting it from outside it work fine. (7 Replies)
Discussion started by: ravi214u
7 Replies

8. HP-UX

ftp first connection closed

Hi, Have anyone seen this problem, there is one remote side where their ftp connection to our server will always fail with connection closed by remote host and the second connection will be working. is this an OS issue or network issue? Thanks Robert (4 Replies)
Discussion started by: robertngo
4 Replies

9. Solaris

Solaris 10 ftp connection problem (connection refused, connection timed out)

Hi everyone, I am hoping anyone of you could help me in this weird problem we have in 1 of our Solaris 10 servers. Lately, we have been having some ftp problems in this server. Though it can ping any server within the network, it seems that it can only ftp to a select few. For most servers, the... (4 Replies)
Discussion started by: labdakos
4 Replies

10. Shell Programming and Scripting

FTP Connection die out

Hi, I will ftp aroung 80 files after connecting to an FTP Server. But after 2 minutes of connection, it is timed out and connection is dying. Server had a 2 minute connection timeout if connection is idle. But my question, Isn't tranfering files not considered as an activity. Is the connection... (7 Replies)
Discussion started by: vasuarjula
7 Replies
FTP_FGET(3)								 1							       FTP_FGET(3)

ftp_fget - Downloads a file from the FTP server and saves to an open file

SYNOPSIS
bool ftp_fget (resource $ftp_stream, resource $handle, string $remote_file, int $mode, [int $resumepos]) DESCRIPTION
ftp_fget(3) retrieves $remote_file from the FTP server, and writes it to the given file pointer. PARAMETERS
o $ftp_stream - The link identifier of the FTP connection. o $handle - An open file pointer in which we store the data. o $remote_file - The remote file path. o $mode - The transfer mode. Must be either FTP_ASCII or FTP_BINARY. o $resumepos - The position in the remote file to start downloading from. RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 ftp_fget(3) example <?php // path to remote file $remote_file = 'somefile.txt'; $local_file = 'localfile.txt'; // open some file to write to $handle = fopen($local_file, 'w'); // set up basic connection $conn_id = ftp_connect($ftp_server); // login with username and password $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); // try to download $remote_file and save it to $handle if (ftp_fget($conn_id, $handle, $remote_file, FTP_ASCII, 0)) { echo "successfully written to $local_file "; } else { echo "There was a problem while downloading $remote_file to $local_file "; } // close the connection and the file handler ftp_close($conn_id); fclose($handle); ?> SEE ALSO
ftp_get(3), ftp_nb_get(3), ftp_nb_fget(3). PHP Documentation Group FTP_FGET(3)
All times are GMT -4. The time now is 03:08 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy