Sponsored Content
Full Discussion: Ftp script with date
Top Forums Shell Programming and Scripting Ftp script with date Post 302999870 by apmcd47 on Thursday 29th of June 2017 04:29:12 AM
Old 06-29-2017
Quote:
Originally Posted by fretagi
that worked fine. But on the same line if I want to transfer the last file of the directory, like from this directory:
Code:
-rw-r--r--   1 rundamo  rundamo   746814 Jun 25 02:20 RundamoSettlement_1498349224609.csv
-rw-r--r--   1 rundamo  rundamo   640038 Jun 26 02:19 RundamoSettlement_1498435659922.csv
-rw-r--r--   1 rundamo  rundamo   645657 Jun 27 02:19 RundamoSettlement_1498522015755.csv
-rwxr-xr-x   1 rundamo  rundamo      202 Jun 27 14:39 ftp_tranf.sh
-rw-r--r--   1 rundamo  rundamo   668370 Jun 28 02:16 RundamoSettlement_1498608378768.csv
-rw-r--r--   1 rundamo  rundamo   670705 Jun 29 02:20 RundamoSettlement_1498694810954.csv
-bash-3.00$

in this case just the :
Code:
-rw-r--r--   1 rundamo  rundamo   670705 Jun 29 02:20 RundamoSettlement_1498694810954.csv

what could I be using
You could use one of these constructs:
Code:
myfile=$(ls -r $(date +'*%Y-%m-%d*') | head -1)
ls -r $(date +'*%Y-%m-%d*') | read myfile

Also do not put a password in a script! Use the .netrc file for storing your FTP servers:
Code:
machine 192.168.6.47 login user123 password mypass

and make it readable only by yourself.
Code:
#!/bin/sh
HOST=192.168.6.47
cd /home/user123/scripts/loadDadosAppWeb/relatorios/25
myfile=$(ls -r $(date +'*%Y-%m-%d*') | head -1)
/usr/bin/ftp -iv ${HOST}<<EOF
binary
put "${myfile}"
bye
EOF

Andrew
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

ftp by date filter

i would be grateful if someone could supply me with a shell script which performed a ftp but only retrieved files which had a created date greater than a specific date - is this possible with ftp? many thanks mc (1 Reply)
Discussion started by: campbem
1 Replies

2. Shell Programming and Scripting

automated ftp script from unix -date range of files

Hi , I need some help to finish my ftp script and i need to find the last one weeks of fles updated in the sepecific directory and see those end with Z and ftp them to my backup server. Any help is appreciated. Thanks, Ravi :) (1 Reply)
Discussion started by: koduri0475
1 Replies

3. Programming

automated ftp script from unix -date range of files

Hi , I need some help to finish my ftp script and i need to find the last one weeks of fles updated in the sepecific directory and see those end with Z and ftp them to my backup server. Any help is appreciated. Thanks, Ravi :) (1 Reply)
Discussion started by: koduri0475
1 Replies

4. UNIX for Advanced & Expert Users

automated ftp script from unix -date range of files

Hi , I need some help to finish my ftp script and i need to find the last one weeks of fles updated in the sepecific directory and see those end with Z and ftp them to my backup server. Any help is appreciated. Thanks, Ravi :) (1 Reply)
Discussion started by: koduri0475
1 Replies

5. Shell Programming and Scripting

Automated FTP script using .netrc to multiple FTP servers

Hi all, I'm using the following script to automated ftp files to 1 ftp servers host=192.168.0.1 /usr/bin/ftp -vi >> $bkplog 2>&1 <<ftp open $host bin cd ${directory} put $files quit ftp and the .netrc file contain machine 192.168.0.1 login abc... (4 Replies)
Discussion started by: varu0612
4 Replies

6. UNIX for Dummies Questions & Answers

How to view date during FTP

date command does not work during FTP. how can we view the system or server date during FTP. (2 Replies)
Discussion started by: Shell_Learner
2 Replies

7. Shell Programming and Scripting

append date time stamp via ftp script

I have searched several thread and not found my solution, so I am posting a new qustion. I have a very simple script on an AIX server that FTPs 2 files to a MS FTP server. These 2 files are created on the AIX server every hour, with a static name. I need to FTP the files to the MS server, but... (1 Reply)
Discussion started by: sknisely
1 Replies

8. Shell Programming and Scripting

FTP script date based

Have Solaris 10 server and a 2008 server.:cool: Would like to FTP files from Solaris server into the 2008 server.:rolleyes: FTP to be executed by 2008 scheduler on a daily basis.:p FTP need to copy files 1 day old (on the Solaris), current Solaris folder holds more than 90 files, only last one... (1 Reply)
Discussion started by: pointer
1 Replies

9. Shell Programming and Scripting

How to FTP the latest file, based on date, from a remote server through a shell script?

How to FTP the latest file, based on date, from a remote server through a shell script? I have four files to be FTP'ed from remote server. They are of the following format. build1_runtime_mmddyyyy.txt build2_runtime_mmddyyyy.txt build3_runtime_mmddyyyy.txt buifile_count_mmddyyyy.txt ... (9 Replies)
Discussion started by: imran_affu
9 Replies

10. Shell Programming and Scripting

Ftp files with date

Hi, i need to put files with current date at end from one server to another. i.e. all the output files from below comand. ls -ltr `date '+monthly_stats.sh%y%m%d'` am using mput `date '+monthly_stats.sh%y%m%d'` but no files are transfered Connected to gbdsnh18.hartfordlife.com. 220... (5 Replies)
Discussion started by: Simanto
5 Replies
ADSL-SETUP(8)						      System Manager's Manual						     ADSL-SETUP(8)

NAME
adsl-setup - Shell script to configure Roaring Penguin PPPoE client SYNOPSIS
adsl-setup DESCRIPTION
adsl-setup is a shell script which prompts you for various pieces of information and sets up an /etc/sysconfig/network-scripts/ifcfg-ppp0 configuration script for the adsl-start, adsl-stop and adsl-connect scripts. AUTHOR
adsl-setup was written by David F. Skoll <dfs@roaringpenguin.com>. The pppoe home page is http://www.roaringpenguin.com/pppoe/. SEE ALSO
pppoe(8), adsl-start(8), adsl-stop(8), adsl-connect(8), pppd(8), pppoe.conf(5), adsl-status(8), pppoe-sniff(8), pppoe-relay(8), pppoe- server(8) 4th Berkeley Distribution 21 February 2000 ADSL-SETUP(8)
All times are GMT -4. The time now is 12:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy