Was willst du denn erreichen? So wie dein Code jetzt ist, ist die Ausgabe jedenfalls korrekt (2 Matches in der 1. Datei, 2 Matches in der 2. Datei, 2*2 => 4 mal Ausgabe).
Sorry
ich will erreichen das mir als variable i der alte name und als j der neue Name gegeben wird den ich dann an ein FTP Script übergebe welches mir auf einem Remot FTP Dateien umbenennt.
Ich muß die Dateien auf dem Remote FTP Server die mit ??? beginnen remote auf dem Server nach NEU* umbenennen, erst dann darf ich diese zu mir holen damit diese verarbeitet werden können.
#Fragezeichen Dateien auslesen
/root/ftp_auslesen.sh > /root/dir
#Fragezeichen Dateien umbenennen
sed -e 's/???/KNV/g' /root/dir|grep KNV > /root/dir_new
for i in `grep "???" /root/dir`; do
for j in `grep "KNV" /root/dir_new`; do
/root/rename.sh $i $j
done
done
#Umbenannte Dateien holen
cd $ZIEL
/root/get.sh
#Temp KNV dir loeschen
rm /root/dir
rm /root/dir_new
#!/bin/bash
ZIEL=""
FTPSERVER="ftp.domain.tld"
function ftp_rename() {
ftp ${FTPSERVER} <<EOF
cd /doc/Test
rename "${1}" "${2}"
EOF
}
function ftp_nlist() {
ftp ${FTPSERVER} <<EOF
cd /doc/Test
nlist
EOF
}
function ftp_get() {
ftp ${FTPSERVER} <<EOF
cd /doc/Test
mget NEU*
a
mdelete NEU*
a
EOF
}
for i in `ftp_nlist | grep "???"`; do
ftp_rename "${i}" "$(sed -e 's/???/KNV/g' -i "${i}")"
done
cd $ZIEL
ftp_get
„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.
#!/bin/bash
ZIEL=""
FTPSERVER="ftp.domain.tld"
function ftp_rename() {
ftp ${FTPSERVER} <<EOF
cd /doc/Test
rename "${1}" "${2}"
EOF
}
function ftp_nlist() {
ftp ${FTPSERVER} <<EOF
cd /doc/Test
nlist
EOF
}
function ftp_get() {
ftp ${FTPSERVER} <<EOF
cd /doc/Test
mget NEU*
a
mdelete NEU*
a
EOF
}
for i in `ftp_nlist | grep "???"`; do
ftp_rename "${i}" "$(sed -e 's/???/KNV/g' "${i}")"
done
cd $ZIEL
ftp_get
„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.
#!/bin/bash
ZIEL=""
FTPSERVER="ftp.domain.tld"
function ftp_rename() {
ftp ${FTPSERVER} <<EOF
cd /doc/Test
rename "${1}" "${2}"
EOF
}
function ftp_nlist() {
ftp ${FTPSERVER} <<EOF
cd /doc/Test
nlist
EOF
}
function ftp_get() {
ftp ${FTPSERVER} <<EOF
cd /doc/Test
mget NEU*
a
mdelete NEU*
a
EOF
}
for i in `ftp_nlist | grep "???"`; do
ftp_rename "${i}" "${i/???/KNV}"
done
cd $ZIEL
ftp_get
Bei Bedarf könnte man auch noch grep ersetzen und statt dem externen ftp das von bash bereitgestellte /dev/tcp nutzen ;)
„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.
„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.
Sorry, aber den sed brauch ich doch um das ??? mit KNV zu ersetzen oder?
ich habe es nun so gelöst, da sed nicht arbeitet wenn ich ihm eine Variable vorwerfe.
„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.
Danke, nun klappt alles.
Kann man das FTP irgendwie noch ergänzen das remote die Dateien erste gelöscht werden wenn Sie wirklich komplett runtergeladen wurden.
„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.
Commands may be abbreviated. Commands are:
! cd edit glob ls mode open proxy remopts sendport tenex xferbuf
$ cdup epsv4 hash macdef modtime page put rename set throttle ?
account chmod exit help mdelete more passive pwd reset site trace
append close features idle mdir mput pdir quit restart size type
ascii cr fget image mget msend pls quote rhelp sndbuf umask
bell debug form lcd mkdir newer pmlsd rate rmdir status unset
binary delete ftp less mls nlist preserve rcvbuf rstatus struct usage
bye dir gate lpage mlsd nmap progress recv runique sunique user
case disconnect get lpwd mlst ntrans prompt reget send system verbose
„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.
„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.
Hi Markus,
wie macht das ncftpget denn, der hat doch eine Funktion dateien erst nach erfolgreichem Download auf der Gegenseite löscht wenn man -DD verwendet.
Gruß Christian
BofH excuses: YOU HAVE AN I/O ERROR -> Incompetent Operator error
Dort wird lediglich die übertrage Anzahl Bits mit der Dateigrösse verglichen, was bekanntlich keine Rückchlüsse auf die Datenintegrität zulässt: Bits kippen hin und wieder auch mal um ;)
„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.