Am trying a shell script for ftp process on Solaris
I am trying to mget files to
Destination server: myserverxxx1
folder : /backup/dumps/SERVER-1backup/afterbatch
From
Source server: SERVER-1
folder : /dumps/daily/backupafterbatch/Thu21Oct_04:22:37
depending on the date the folder can be
/dumps/daily/backupafterbatch/Fri22Oct_04:25:13
/dumps/daily/backupafterbatch/Sat23Oct_04:25:07
i have to cd to the latest folder
in this case
/dumps/daily/backupafterbatch/Sat23Oct_04:25:07
I am unable to cd to the latest date folder
my script is as under(## in destination server ## sunftp)
#!/bin/bash
cd backup/dumps/kplusbackup/afterbatch
ftp SERVER-1
I am using .netrc macdef init ,
my .netrc file is as below (## in destination server)
machine SERVER-1 login sunny password sunny12 macdef init
cd /dumps/daily/backupafterbatch
ls -lrt "|tail -1 | cut -c 55-79-exec cd \{} \;"
pwd
ls -lrt
executing the script as under
sunny@mydb1 $ . ./sunftp
output is like
Connected to SERVER-1
220 SERVER-1 FTP server ready.
331 Password required for sunny.
230 User sunny logged in.
cd /dumps/daily/backupafterbatch
250 CWD command successful.
ls -lrt "|tail -1 | cut -c 55-79 -exec cd {} ;"
200 PORT command successful.
150 Opening ASCII mode data connection for /bin/ls.
226 Transfer complete.
local: ; remote: -lrt
228 bytes received in 0.009 seconds (24.65 Kbytes/s)
pwd
257 "/dumps/daily/backupafterbatch" is current directory.
ls -lrt
200 PORT command successful.
150 Opening ASCII mode data connection for /bin/ls.
total 6
drwxr-xr-x 2 sybase kadmin 512 Oct 21 04:22 Thu21Oct_04:22:37
drwxr-xr-x 2 sybase kadmin 512 Oct 22 04:25 Fri22Oct_04:25:13
drwxr-xr-x 2 sybase kadmin 512 Oct 23 04:25 Sat23Oct_04:25:07
226 Transfer complete.
remote: -lrt
228 bytes received in 0.023 seconds (9.68 Kbytes/s)
ftp> bye
221-You have transferred 0 bytes in 0 files.
221-Total traffic for this session was 1013 bytes in 2 transfers.
221-Thank you for using the FTP service on SERVER-1.
221 Goodbye.
-lrt: not found
If I am successful in entering into the latest folder i will mget ,can anyone guide me please
Thanks in advance