- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Need help creating a script
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
Forums
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
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
02-19-2011 01:46 AM
02-19-2011 01:46 AM
Requirements are :
Client will place file of format XXEGO_PIM_HEADERS_DDMMYYYY.DAT in souce directory let us say A and script need to move it to directory B and once it get moved the format of file should look like ILE512_PIM_EXTRACT1.DAT...I am new to scripting, please help ASAP.
Also I just created a script in which client have placed a file in format FILE500_SITEDB.CSV_YYMMDDHHMM and it should get copy to another direcorty without that time stamp and please see the script below which is working now...however in the above request I am unable to identify how it will serach for this pattern..XXEGO_PIM_HEADERS_DDMMYYYY.DAT ..Please help!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2011 06:29 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2011 06:38 AM
02-19-2011 06:38 AM
Re: Need help creating a script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2011 06:42 AM
02-19-2011 06:42 AM
Re: Need help creating a script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2011 09:20 PM
02-19-2011 09:20 PM
Re: Need help creating a script
First of ALL thanks a ton for your support :)
YOur script is very good ..I tried it on test server and it is working well..
I have also created script yesterday (Please find it attached)which is working fine..however yours is simple and easy...
I have one question..
In one Script, the client will place the file in the format.
File will come in this format : XXEGO_GL_DDMMYYYY.DAT
Source Directory:
/u03/UBIDW/data/backup Destination Directory:
/u03/UBIDW/data/inbound/FILE511_PIM_GL.TXT
Operation: Copy the fiole from source to destination...
When it move in to destination directory its name should be like
FILE511_PIM_GL.TXT
without timestamp...and name changed as well...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2011 02:09 AM
02-20-2011 02:09 AM
Re: Need help creating a script
The destination filename have a specific creation rule, or just always will be FILE511_PIM_GL.TXT?
Rgds.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2011 02:49 AM
02-20-2011 02:49 AM
Re: Need help creating a script
Also script should only pick up with file containing XXEGO_PIM_HEADERS with Latest time stamp in source directory....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2011 03:25 AM
02-20-2011 03:25 AM
Re: Need help creating a script
SOURCE_DIR=/u03/UBIDW/data/backup
TARGET_DIR=/u03/UBIDW/data/inbound
cd $SOURCE_DIR
FILE_TO_MOVE=`ls -ltr XXEGO_GL_*.DAT|tail -1|awk '{ print $9 }'`
mv ${FILE_TO_MOVE} ${TARGET_DIR}/FILE511_PIM_GL.TXT
Please try and tells me something...
Rgds.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2011 03:36 AM
02-20-2011 03:36 AM
Re: Need help creating a script
Let us say if there is a file present in the source dir with previous date stamp and with latest date stamp will it be able to pick the file with latest date time stamp?
Scripts looks good it work well :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2011 04:20 AM
02-20-2011 04:20 AM
Re: Need help creating a script
I'm listing files XXEGO_GL_*.DAT with reverse time creation. With this, files are sorted placing the most recient file at end of the list, then "tail -1" always show the last file of the list. Please note that I am evaluating the file creation time on the system.
A possible issue, imagine this situation: you have these four files:
XXEGO_GL_17022011.DAT
XXEGO_GL_18022011.DAT
XXEGO_GL_19022011.DAT
XXEGO_GL_20022011.DAT
At first time the script will move the last file XXEGO_GL_20022011.DAT, but if this script run again the file XXEGO_GL_19022011.DAT will be moved, and so on.
A good control could be set a reference timestamp variable that ensure move only certain files that match date:
SOURCE_DIR=/u03/UBIDW/data/backup
TARGET_DIR=/u03/UBIDW/data/inbound
TODAY=`date +%d%m%Y`
cd $SOURCE_DIR
FILE_TO_MOVE=`ls -ltr XXEGO_GL_${TODAY}.DAT|tail -1|awk '{ print $9 }'`
if [ "$FILE_TO_MOVE" = "" ]
then
echo "Today's file has yet not arrived"
exit 6
fi
mv ${FILE_TO_MOVE} ${TARGET_DIR}/FILE511_PIM_GL.TXT
exit 0
I hope this is useful...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2011 04:34 AM
02-20-2011 04:34 AM
Re: Need help creating a script
I got all my answers
Again Thanks a ton for our support :)
Have a great d ay ahead !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2011 04:44 AM
02-20-2011 04:44 AM
Re: Need help creating a script
Glad to assist you, and best regards.