- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Writing a script for single file transfer to all s...
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
тАО07-25-2002 10:55 AM
тАО07-25-2002 10:55 AM
Writing a script for single file transfer to all servers
I am new to writing scripts and HP-UX, so the question I have, I am sure is very simple to a lot of you so please excuse.
I need to transfer a single file from one UNIX server to the rest of our UNIX servers in the same domain, I was wondering how (examples or suggestions) I could write a script that would help me do this so I don???t have to login into each and every server to copy this file. By the way I would like to do this in korn shell environment.
Thanks in advance,
Evans
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-25-2002 11:10 AM
тАО07-25-2002 11:10 AM
Re: Writing a script for single file transfer to all servers
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-25-2002 11:11 AM
тАО07-25-2002 11:11 AM
Re: Writing a script for single file transfer to all servers
#!/usr/bin/sh
MACHINES="daffy donald mickey minnie pluto goofy"
for i in $MACHINES
do
rcp /dir/filename $i:/dir/filenameecho "file copied to $i"
done
This should get you pointed in the right direction. I make no guarantees on the syntax since I don't have a machine to test on at the moment.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-25-2002 11:15 AM
тАО07-25-2002 11:15 AM
Re: Writing a script for single file transfer to all servers
the way i should do it
- create a file ex. ftpserver.conf
here your put the servers where to
put a file
server1
server2
...
- Second you create the script :
login=
password=
remote_path=
remote_file=
while read server_name
do
ftp -nv << BeginFtp
open ${server_name}
user ${login} ${password}
prompt
cd ${remote_path}
mput ${remote_file}
bye
BeginFtp
done < ftpserver.conf
note that is just an example , did test
if it works , but normally it should.
It also not really secure because the
password is hardcoded in the script.
Regards,
Steven
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-25-2002 11:53 AM
тАО07-25-2002 11:53 AM
Re: Writing a script for single file transfer to all servers
#!/usr/bin/ksh
syslist="sys1 sys2 sys3 sys4 sys5"
syslist=$(echo $syslist | sed "s/$(hostname)//")
for sys in $syslist
do
if `rcp /etc/motd $sys:/etc/motd`
then echo "Copied to $sys..."
else echo "Copy to $sys FAILED..."
fi
done
echo "** Done now!"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-25-2002 11:57 AM
тАО07-25-2002 11:57 AM
Re: Writing a script for single file transfer to all servers
Perfect, but now I need to change permission of owner and group to root and sys. Any suggestions I would appreciate.
Thanks everyone for the direction and quick response. Wow! You guys/gals are great! Nice forum.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-25-2002 11:59 AM
тАО07-25-2002 11:59 AM
Re: Writing a script for single file transfer to all servers
#!/usr/bin/sh
MACHINES="daffy donald mickey minnie pluto goofy"
for i in $MACHINES
do
rcp /dir/filename $i:/dir/filename
remsh $i chown root:sys /dir/file
echo "file copied to $i"
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-25-2002 12:00 PM
тАО07-25-2002 12:00 PM
Re: Writing a script for single file transfer to all servers
use
remsh REChostname chown root:sys filepath_on_RECHOST
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-25-2002 03:47 PM
тАО07-25-2002 03:47 PM
Re: Writing a script for single file transfer to all servers
The issue that I am running into now is that I get and error because the file already exists on these servers and when I try to move it to an old name (which I would like to do) I get permission denied. Now I am assuming this is because the ID that I am trying to use doesn???t have permission to do an rm or an mv.
Thanks again everyone.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-25-2002 04:17 PM
тАО07-25-2002 04:17 PM
Re: Writing a script for single file transfer to all servers
That way you only have to maintain the file in one place.
To do this you need to create a filesystem, make sure that the nfs daemons are running, add the filesystem name to /etc/exports and then run the command exportfs -a.
Then on the other systems create a directory with the same name & then create an entry in /etc/fstab to mount the remote filesystem or at command line enter - mount machine1:/nfsdir /nfsdir
Its actually a little more involved than that but its way past my bedtime - This should give you a few pointers to do some searches on this forum for more in depth use of NFS (Also see SAMBA or CIFS.)