friends
good morning
FTP works perfect but I have a doubt
if I want to transport 10 files, I imagine that I should not open 10 connections as I can transfer more than 1 file?
ftp -n <<!EOF
open caburga
user ephfact ephfact
cd /users/efactura/docONE/entrada
bin
mput EPH`date +%Y%m%d`XXFF_cc_01.REC EPH`date +%Y%m%d`XXFF_cc_01.CTR
quit
!EOF
tricampeon81:
friends
good morning
FTP works perfect but I have a doubt
if I want to transport 10 files, I imagine that I should not open 10 connections as I can transfer more than 1 file?
ftp -n <<!EOF
open caburga
user ephfact ephfact
cd /users/efactura/docONE/entrada
bin
mput EPH`date +%Y%m%d`XXFF_cc_01.REC EPH`date +%Y%m%d`XXFF_cc_01.CTR
quit
!EOF
Just transfer all files on the same connection. use
mput EPH`date +%Y%m%d`*.REC EPH`date +%Y%m%d`*.CTR
If the number is all that changes in the 'XXFF_CC_01' part
FTP Multiple Files
1 Like
what happens is that I have a list of files and that list I must pass to the connection and send the files for example
file_1.tmp
content
test1.txt
test2.txt
test3.txt
and each of them are files that I have to send, that list is dynamic
cat <<!EOF
open caburga
user ephfact ephfact
cd /users/efactura/docONE/entrada
bin
mput EPH`date +%Y%m%d`XXFF_cc_01.REC EPH`date +%Y%m%d`XXFF_cc_01.CTR
`xargs printf "put %s" < file_1.tmp"`
quit
!EOF
This won't connect to FTP, just print the commands to console, for you to check that it's what you wanted. It ought to add a put filename for every file in your file_1.tmp
Once you're sure it looks right, replace cat with ftp -n.
RudiC
February 20, 2019, 4:15pm
5
Small adaption to Corona688's proposal as mput
accepts multiple file names for its parameters:
cat <<EOF
open caburga
user ephfact ephfact
cd /users/efactura/docONE/entrada
bin
mput EPH$(date +%Y%m%d)XXFF_cc_01.REC EPH$(date +%Y%m%d)XXFF_cc_01.CTR
mput $(tr $'\n' ' ' < file_1.tmp)
quit
EOF
EDIT: Or even
mput EPH$(date +%Y%m%d)XXFF_cc_01.REC EPH$(date +%Y%m%d)XXFF_cc_01.CTR $(tr $'\n' ' ' < file_1.tmp)
2 Likes
hello good afternoon friend
I really could not solve this problem, what I understand is that I must do this
cat <<!EOF
open caburga
user ephfact ephfact
cd /users/efactura/docONE/entrada
bin
mput < file_1.tmp"`
quit
!EOF
RudiC
February 21, 2019, 4:53pm
7
What?
What keeps you from adapting your code from post #1 using one of the proposals given as a guide?
1 Like
Did you try this?
cat <<!EOF
open caburga
user ephfact ephfact
cd /users/efactura/docONE/entrada
bin
mput EPH`date +%Y%m%d`XXFF_cc_01.REC EPH`date +%Y%m%d`XXFF_cc_01.CTR
`xargs printf "put %s\n" < file_1.tmp`
quit
!EOF
I just noticed a rogue quotation mark in it which may have stopped it from working, so try again
1 Like
RudiC pointed out an error in my code. Note "put %s\n" instead of "put %s". Another typo was also fixed.
1 Like
Hello Goodnight
I forgot to put my code, the truth I thought it would be easy but so far I have not been able to solve the solution ...
--- Post updated at 08:12 PM ---
I need to transfer multiple files, by FTP and I have the list in a file, like this
#example
# archive : Arch_Ftp.tmp.Tmp
#
#Data archive
#test_1.txt
#test_2txt
#test_3.txt
#test_4.txt
#test_5.txt
NodoDES3=192.168.80.15
USERftp3=Fxxxxxxx
PASSftp3=Fyyyyyyy
ftp -n 192.168.80.15
quote USER $USERftp3
quote PASS $PASSftp3
ascii
prompt
# INI : this command does not work for me
mput Arch_Ftp.tmp.Tmp
#FIN this command does not work for me
quit
That code does not work for me, and I'm a bit complicated already ...
RudiC
February 22, 2019, 4:09am
11
Now that is a bit sparse. Please show WHAT and HOW "does not work", so we can analyse (and hopefully counteract).
Aside - this new post seems to be different from what you requested in post #1 .
1 Like
if you're right excuse me, I'll try my code again .. and thanks for the help
implement this code and the console is waiting for you to enter the key missing some parameter ??
echo 'open '$HOST'' > mc_comando2.lst
echo 'user '$USER' '$PASSWD'' >> mc_comando2.lst
# echo 'cd '$repositorio_destino >> mc_comando2.lst
echo 'prompt off' >> mc_comando2.lst
echo 'mput '$FILTRO'' >> mc_comando2.lst
ftp -n < mc_comando2.lst
For the third time in a row:
ftp -n <<!EOF
open caburga
user ephfact ephfact
cd /users/efactura/docONE/entrada
bin
mput EPH`date +%Y%m%d`XXFF_cc_01.REC EPH`date +%Y%m%d`XXFF_cc_01.CTR
`xargs printf "put %s\n" < file_1.tmp`
quit
!EOF
This time I have done the onerous task of substituting ftp -n for cat, for you. Try the above code and get back to me.
Ignore suggested solutions a third time and I will lock your thread.
3 Likes
look how the code is at the end.
just can not just make a call to ftp, I had to put it inside a while
ORA_LOGIN=Fyyyyyyyy
ORA_PASSWORD=Fxxxxxxx
ORACLE_SID=PBSEGD
export ORA_LOGIN
export ORA_PASSWORD
export ORACLE_SIDA
FchInput=$1
TmpArch="AbonoTmp_"
TmpExt=".Tmp"
FILTRO="AbonoTmp_20190222.Tmp"
#HOST
HOST="192.168.80.15"
USER="Fxxxxxxx"
PASSWD="Fyyyyyyy"
echo "Inicio Proceso cesantia por favor espere...." > receparchcta_$fecha.log
#ini nombre archivo
# Ini rescato lista de nombre de archivos
cat << EOF | sqlplus -s ${ORA_LOGIN}/${ORA_PASSWORD}@${ORACLE_SID} > AbonoTmp_$FchInput.Tmp
set feedback off
set echo OFF
set sqlnumber off
set serveroutput on size unlimited
set trimout off
set trimspool off
DECLARE
RC1 fidensctrl.globalPkg.RCT1;
BEGIN
SP_SIN_GNRARCHABOCTARSAT (6,'$FchInput',1,1,RC1);
END;
/
exit;
EOF
#fin nombre archivo
ARCHCES=$TmpArch$FchInput$TmpExt
echo "NOMBRE DE ARCHIVO:" $ARCHCES >> receparchcta_$fecha.log
#while read line; do
#echo "$line";
#done < $ARCHCES
#exit 88
#para archivo cesantia
if [ -f $ARCHCES ];
then
echo "existen registro, para Archivo cesantia:" $ARCHCES >> receparchcta_$fecha.log
total=`wc -l $ARCHCES | cut -c1-8`
echo "Cantidad de Registro:" $total >> receparchcta_$fecha.log
if [ $total -ne 0 ];
then
echo "existen registro, para Archivo :" >> receparchcta_$fecha.log
#ini ejecuto FTp tantas veces archivos existan
while read line; do
echo 'open '$HOST'' > mc_comando2.lst
echo 'user '$USER' '$PASSWD'' >> mc_comando2.lst
echo 'prompt off' >> mc_comando2.lst
echo 'mput '$line'' >> mc_comando2.lst
echo 'close' >> mc_comando2.lst
echo 'bye' >> mc_comando2.lst
ftp -n < mc_comando2.lst >> receparchcta_$fecha.log
echo 'VERIFICANDO EL ENVIO.....' ? >> receparchcta_$fecha.log
#fin actualizo archivo
done < $ARCHCES
else
echo "NO existen registro, para Archivo :" >> receparchcta_$fecha.log
fi
else
echo "No existen registro,para archivo cesantia: " $ARCHCES >> receparchcta_$fecha.log
fi
#ini actualizado archivo
cat << EOF | sqlplus -s ${ORA_LOGIN}/${ORA_PASSWORD}@${ORACLE_SID} >> receparchcta_$fecha.log
set feedback off
set echo OFF
set sqlnumber off
set serveroutput on size unlimited
set trimout off
set trimspool off
DECLARE
RC1 fidensctrl.globalPkg.RCT1;
BEGIN
SP_SIN_GNRARCHABOCTARSAT (7,'$FchInput',1,1,RC1);
END;
/
exit;
EOF
rm -f mc_comando2.lst
rm -f AbonoTmp_$FchInput.Tmp
exit 0
it works perfect to send multiple file but I did not like having to put the FTP inside a while
As promised, thread locked. We cannot help you without feedback.
2 Likes
RudiC
February 22, 2019, 11:27am
17
Please, please, have mercy with us!
Please, please, give us some reliable, consistent data to build upon.
Where in that code do we find your code snippet from post #1 , and where file_1.tmp
from post #3 ? Where do we find your attempts to include / adapt the proposals you received? How do you expect anybody to deal with those moving targets and to guess what be the input file and its structure?
2 Likes