- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to get the filename_xxx.tgz to 2003-11-03-2359...
Operating System - HP-UX
1825001
Members
2617
Online
109678
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
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
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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
тАО11-03-2003 05:56 AM
тАО11-03-2003 05:56 AM
How to get the filename_xxx.tgz to 2003-11-03-235900.tgz
hi all,
A shell script question.
In my system, everyday 4 log files will be generated.
2003-11-03-235900.log
2003-11-03-235900.logaaaa
2003-11-03-235900.logbbb
2003-11-03-235900.logcc
I want to tar/gzip them.
tar cvf - $FWDIR/log/20??-??-??-2359??.log* | gzip -9 > /tmp/filename_xxx.tgz.
My question is how can I get the filename_xxx.tgz into 2003-11-03-235900.tgz???
Also after the compression I want to ftp the 2003-11-03-235900.tgz to the ftp server.
I had made some kinds of script like this, do you think it will works??
**************************************************************
more /scripts/ftp_script.sh
#!/usr/bin/sh
ftp -n -v << EOF > /tmp/filename_xxx.ftplog
open hostname
user admin password
bin
cd $FWDIR/log/
lcd /backup/
put *.tgz
bye
EOF
STATUS=`grep Complete /tmp/filename_xxx.ftplog`
if [[ $STATUS == "Complete" ]]; then
rm filename_xxx.log*
ERROR=0
else
ERROR=1
fi
exit $ERROR
**************************************************************
Thanks
//john
A shell script question.
In my system, everyday 4 log files will be generated.
2003-11-03-235900.log
2003-11-03-235900.logaaaa
2003-11-03-235900.logbbb
2003-11-03-235900.logcc
I want to tar/gzip them.
tar cvf - $FWDIR/log/20??-??-??-2359??.log* | gzip -9 > /tmp/filename_xxx.tgz.
My question is how can I get the filename_xxx.tgz into 2003-11-03-235900.tgz???
Also after the compression I want to ftp the 2003-11-03-235900.tgz to the ftp server.
I had made some kinds of script like this, do you think it will works??
**************************************************************
more /scripts/ftp_script.sh
#!/usr/bin/sh
ftp -n -v << EOF > /tmp/filename_xxx.ftplog
open hostname
user admin password
bin
cd $FWDIR/log/
lcd /backup/
put *.tgz
bye
EOF
STATUS=`grep Complete /tmp/filename_xxx.ftplog`
if [[ $STATUS == "Complete" ]]; then
rm filename_xxx.log*
ERROR=0
else
ERROR=1
fi
exit $ERROR
**************************************************************
Thanks
//john
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-03-2003 06:07 AM
тАО11-03-2003 06:07 AM
Re: How to get the filename_xxx.tgz to 2003-11-03-235900.tgz
Hey John,
For the renaming of the file I would do something like this in your script:
DATE=`date "+%Y-%m-%d-"
tar cvf - $FWDIR/log/20??-??-??-2359??.log* | gzip -9 > /tmp/${DATE}235900.tgz
Hope this helps!
-Bryan
For the renaming of the file I would do something like this in your script:
DATE=`date "+%Y-%m-%d-"
tar cvf - $FWDIR/log/20??-??-??-2359??.log* | gzip -9 > /tmp/${DATE}235900.tgz
Hope this helps!
-Bryan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-03-2003 06:13 AM
тАО11-03-2003 06:13 AM
Re: How to get the filename_xxx.tgz to 2003-11-03-235900.tgz
Hey John,
Let me correct something:
What I posted previously:
DATE=`date "+%Y-%m-%d-"
Should have been this:
DATE=`date "+%Y-%m-%d-"`
-Bryan
Let me correct something:
What I posted previously:
DATE=`date "+%Y-%m-%d-"
Should have been this:
DATE=`date "+%Y-%m-%d-"`
-Bryan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-03-2003 08:25 AM
тАО11-03-2003 08:25 AM
Re: How to get the filename_xxx.tgz to 2003-11-03-235900.tgz
John,
With a 2line script it is pretty simple.
FILENAME=`ls 20??-??-??-2359??.log | cut -f 1 -d "."`
tar cvf - $FWDIR/log/${FILENAME}.log* | gzip -9 > /tmp/$(FILENAME}.tgz
Of course, better would be to create the variable FILENAME in function of an argument of your little script. Where that argument is the date.
Something like this
FILENAME=`ls ${1}-235900.log | cut -f 1 -d "."`
tar cvf - $FWDIR/log/${FILENAME}.log* |gzip -9 > /tmp/$(FILENAME}.tgz
If you call your script "ziplog", then you can execute
./ziplog 2003-11-03
Hope it inspires
Joris
With a 2line script it is pretty simple.
FILENAME=`ls 20??-??-??-2359??.log | cut -f 1 -d "."`
tar cvf - $FWDIR/log/${FILENAME}.log* | gzip -9 > /tmp/$(FILENAME}.tgz
Of course, better would be to create the variable FILENAME in function of an argument of your little script. Where that argument is the date.
Something like this
FILENAME=`ls ${1}-235900.log | cut -f 1 -d "."`
tar cvf - $FWDIR/log/${FILENAME}.log* |gzip -9 > /tmp/$(FILENAME}.tgz
If you call your script "ziplog", then you can execute
./ziplog 2003-11-03
Hope it inspires
Joris
To err is human, but to really faul things up requires a computer
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Learn About
News and Events
Support
© Copyright 2025 Hewlett Packard Enterprise Development LP