- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- fetch the last file in directory
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2014 11:41 PM
09-30-2014 11:41 PM
fetch the last file in directory
Hi
I have a scritp that ftp to a server to get a file, with following format HLRxx_mmddyyyy, where xx is 04 and mm is the month, dd= day and yyyy = year.
My script:
#!/usr/bin/sh cd /moneta_polled01/download1 HOST=10.100.48.47 USER=hlr_dump PASSWD=dump123 /usr/bin/ftp -nv $HOST <<EOF user $USER $PASSWD binary mget *HLR* bye EOF
as it is gets all HLR files, but I just want the last,
Please can you give me a hint?
- Tags:
- ftp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2014 10:41 AM
10-01-2014 10:41 AM
Re: fetch the last file in directory
>gets all HLR files, but I just want the last,
To get the last file requires you to first do a ls to get the list of files, then you can do a get.
And hope nothing changes between the two ftp sessions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2014 11:58 PM
10-01-2014 11:58 PM
Re: fetch the last file in directory
Hi
But the source server is a windows system, so I can use a "dir" command but how to actually getting the last file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2014 12:36 AM
10-02-2014 12:36 AM
Re: fetch the last file in directory
>the source server is a windows system, so I can use a "dir"
ls should work too.
>how to actually getting the last file
For Unix/Linux, you can use "ls -t" and the latest will be at the beginning, add -r for end.
If ftp on Windows actually invokes the DOS dir command, you can use: dir /od
The latest is at the end.
For Unix/Linux you can also put the output into a file.
Note: The options and file needs to be quoted so one parm.
ls "-t *HLR*" out-file