- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: ftp script can't rename the file
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
08-10-2011 04:40 AM
08-10-2011 04:40 AM
ftp script can't rename the file
Hi,
I am running a ftp script to xfer file. Script is expected to rename file upon transmission with current date extension but it does not work. I am attaching my sample script for your review. can you please give some input?
Server>more carrier_gen.txt
open 192.168.50.17
user robertx Password123
put /var/opt/oracle/log/carrier_gen.log carrier_gen.txt_'(date+%m\%d\%y)'
bye
Server> more New_Feed_ftp.sh
#!/usr/bin/sh
#
ftp -i -n < /home/SystemScripts/carrier_gen.txt*
When I put the file I am trying to put it in a different name with current date as an extension to avoid overwriting. I am using back tic around (date+%m\%d\%y).
Thanks
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2011 05:48 AM - edited 08-10-2011 05:54 AM
08-10-2011 05:48 AM - edited 08-10-2011 05:54 AM
Re: ftp script can't rename the file
>can you please give some input?
You need to use a here doc:
#!/usr/bin/sh ftp -i -n <<EOF open 192.168.50.17 user robertx Password123 put /var/opt/oracle/log/carrier_gen.log carrier_gen.txt_$(date +%m%d%y)
bye EOF
Now a real shell will evaluate $(date +%m%d%y) before it is read.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2011 05:50 AM
08-10-2011 05:50 AM
Re: ftp script can't rename the file
@vz7r1x wrote:When I put the file I am trying to put it in a different name with current date as an extension to avoid overwriting. I am using back tic around (date+%m\%d\%y).
You don't appear to have used backticks (at least my copy-and-paste) suggests not. You don't need to escape the "%" characters and in fact you don't want to; and you need a space after 'date' and before the formatting instructions. Instead of backticks, use the POSIX $(...) syntax:
# put /var/opt/oracle/log/carrier_gen.log carrier_gen.txt_$(date +%m%d%y)
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2011 06:23 AM
08-11-2011 06:23 AM
Re: ftp script can't rename the file
Thanks James and Dennis. It resolved my problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2011 01:27 AM
08-12-2011 01:27 AM
Re: ftp script can't rename the file
>Thanks James and Dennis. It resolved my problem.
If you are happy with your answers, please click on the kudos stars and consider marking a solution.