- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Help with 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
Discussions
Discussions
Forums
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
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
тАО10-06-2001 05:58 AM
тАО10-06-2001 05:58 AM
Help with Script
I am trying to write a script with the following requirements.
System A
---------
/hpm30/RCMO.dbf
/hpm31/RCMOtest.dbf
/hpm31/RCMOdata.dbf
/hpm32/RCMOlog.data
These directories also have other files that do not begin with RCMO.
I want to 'find' all files that begin with RCMO
in all the directories and 'tar' all the files
into a tar file which can be 'ftped' to the System B and untarred to the respective directories. These two systems are in two different locations and 'rdist' may not be an option. I get faster transfer rates with FTP.
System B
--------
/hpm30
/hpm31
/hpm31
/hpm32
Thank you - Subbu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-06-2001 07:00 AM
тАО10-06-2001 07:00 AM
Re: Help with Script
One way of doing it is
find hpm* -name RCMO\* -exec tar rvf mydbf.tar {} \;
tar tvf mydbf.tar
In the find command you are looking for files starting with RCMO in directories starting with hpm.
Once the tar file is created, just check the contents using tar tvf.
Look at the man page for find, if you want more options.
-HTH
Ramesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-06-2001 07:05 AM
тАО10-06-2001 07:05 AM
Re: Help with Script
Looks like you asked the same question twice.
http://forums.itrc.hp.com/cm/QuestionAnswer/1,11866,0x15f6c6af36b7d5118ff10090279cd0f9,00.html
-Ramesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-06-2001 07:42 AM
тАО10-06-2001 07:42 AM
Re: Help with Script
This does not answer you question directly, but it is what I would do.....
If you set up equivalences between the two systems you could do the xfr in one go & half the time!!!!
test equivalence on systemA, best as root, but oracle should also be OK
# remsh systemB ls
If this works
# tar cf - $(find
It is important that
Lastly make sure before doing the above that the RCMO files will end up in the right disks/LV's else you'll fill up the wrong filesystem
I hope it all helps
Tim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-06-2001 07:43 AM
тАО10-06-2001 07:43 AM
Re: Help with Script
A workaround could be to get the list of files, again using the find command, and then creating the tar file at one shot, i.e.:
find /hpm* -name RCMO\* > archive.lst
tar cvf mydbf.tar $(cat archive.lst)
also you may want to consider compressing the archive so that it would be faster when you try to transfer it to another system, i.e.:
find /hpm* -name RCMO\* > archive.lst
tar cvf - $(cat archive.lst)|gzip -c > mydbf.tar.gz
Hope this helps.
-Santosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-06-2001 09:35 AM
тАО10-06-2001 09:35 AM
Re: Help with Script
just a simple mixture of "find" and "tar" and
"ftp" should be fine:
tar cvf /tmp/all.tar $(find /hpm30 /hpm31 /hpm32 -name "RCMO*")
and then "ftp" it over and "tar xvf" it over
there.
HTH,
Wodisch
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-06-2001 09:57 AM
тАО10-06-2001 09:57 AM
Re: Help with Script
You can also try this simple way.
tar cvf /tmp/RCM.tar /hpm*/RCM*
FTP /tmp/RCM.tar to system B
and do
a tar xvf /tmp/RCM.tar
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-06-2001 11:39 AM
тАО10-06-2001 11:39 AM
Re: Help with Script
However, if this is a regular task and (some of) these files are large then you could use a batch ftp to accomplish this task (assumptions: both systems have the named directories in $DIRS):
#!/usr/bin/sh
# replicate RCMO files in system B
REMOTECPU="myname.domain.com"
USER=somelogin
PW=somePW
DIRS="/hpm30 /hpm31 /hpm32"
for MYDIR in 30 31 32
do
/usr/bin/ftp -n -v << EOF
open $REMOTECPU
user $USER $PW
lcd $DIRS
cd $DIRS
prompt
binary
mput RCMO\*
bye
EOF
done
--
The RCMO\* needs the \* to prevent the shell's file matching from substituting anything in the local directory where the script is run. We want ftp to see the *, not the shell, since ftp must perform the match.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-07-2001 10:46 AM
тАО10-07-2001 10:46 AM
Re: Help with Script
My suggestion would work if you are using gnu tar, but since that is not a valid assumption i guess you will have to create a list of contents or use one of the other suggestions.
Also i would like to add, you are better of compressing the tar file, to reduce the data to be transfered. Ofcourse you can script all this in one script, to tar, compress, ftp and then telnet to the other system, uncompress and untar the file and remove the tar file after the untar.
-Regards
Ramesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-07-2001 11:03 AM
тАО10-07-2001 11:03 AM
Re: Help with Script
Here is a script that you can modify or use it as it is to tar,uncompress, ftp , telnet to the remote machine, uncompress/untar the file and then delete the tar file on the remote/local machine.
/Begin/
#!/usr/bin/sh
PATH=/usr/bin:/usr/contrib/bin
# Here remote is your remote host
REMOTE=remote
# user is the user you want to ftp as
USER=user
# password of the user
PW=password
# Here /hpm3 can be an absolute path /path/to/hpm3,
DIR=/hpm3
# Files you want to copy to remote host
FILE=RCMO*.dbf
# Name of the tar file
MYTAR=mydbf.tar
#### Do not need to edit below #####
echo " ### Creating the tar file ### "
tar cvf $MYTAR /$DIR*/$FILE
echo " ### Compressing the tar file ### "
gzip $MYTAR
echo "### Transferring the compressed tar file to $REMOTE host ###"
ftp -n -v << EOF
open $REMOTE
user $USER $PW
cd $DIR
prompt
binary
put $MYTAR.gz
bye
EOF
echo "### Logging into the remote host for uncompressing/untarring the file ###"
(sleep 5
echo $USER
sleep 5
echo $PW
sleep 15
echo "gzip -dc $DIR/$MYTAR.gz | tar xvf - "
echo "rm $DIR/$MYTAR.gz"
echo exit) |telnet $REMOTE
echo "### Deleting the tar file on local host ###"
rm $MYTAR.gz
/End/
-HTH
Ramesh