copy config files from one box to another
copy config files from one box to another
am 26.09.2007 11:51:27 von ton de w
Hello,
I have a small but urgent programming task to attend to.
Must write a perl prog, on redhat AS 3.8 to grab a table from a
remote db and create some (config) files - no problem.
These config files need to be fed to an application on another redhat
AS 3.8 box.
So two subtasks, transfer config files across and restart app so the
app reads the config files.
There are identical non-root users on both boxes. And ssh, which I
suppose is the only way to go, is configured as standard. I can
restart the app with a local shell script no problem.
I have done a man ssh and man scp but cannot quite see an easy way of
doing this!
Anyone care to help?
TIA
Tony
Re: copy config files from one box to another
am 26.09.2007 14:09:34 von Icarus Sparry
On Wed, 26 Sep 2007 02:51:27 -0700, ton de w wrote:
> Hello,
> I have a small but urgent programming task to attend to. Must write a
> perl prog, on redhat AS 3.8 to grab a table from a remote db and create
> some (config) files - no problem. These config files need to be fed to
> an application on another redhat AS 3.8 box.
> So two subtasks, transfer config files across and restart app so the app
> reads the config files.
>
> There are identical non-root users on both boxes. And ssh, which I
> suppose is the only way to go, is configured as standard. I can restart
> the app with a local shell script no problem. I have done a man ssh and
> man scp but cannot quite see an easy way of doing this!
>
> Anyone care to help?
>
> TIA
>
> Tony
Well, if you must write a "perl" prog then comp.unix.shell is probably
the wrong pace to ask...
In sh
#!/bin/sh
CF='/the/full/name/of/the/config/file'
scp "$CF" remote_host:"$CF"
ssh remote_host '/the/path/to/the/restarter/script'
A trivial translation to perl would be something like (untested)
#!/usr/bin/perl -w
$CF='/the/full/name/of/the/config/file';
print `scp "$CF" remote_host:"$CF"`';
print `ssh remote_host '/the/path/to/the/restarter/script'`;
This is not exactly a good use of perl!
Re: copy config files from one box to another
am 26.09.2007 23:28:44 von ton de w
On 26 Sep, 13:09, Icarus Sparry wrote:
> On Wed, 26 Sep 2007 02:51:27 -0700, ton de w wrote:
> > Hello,
> > I have a small but urgent programming task to attend to. Must write a
> > perl prog, on redhat AS 3.8 to grab a table from a remote db and create
> > some (config) files - no problem. These config files need to be fed to
> > an application on another redhat AS 3.8 box.
> > So two subtasks, transfer config files across and restart app so the app
> > reads the config files.
>
> > There are identical non-root users on both boxes. And ssh, which I
> > suppose is the only way to go, is configured as standard. I can restart
> > the app with a local shell script no problem. I have done a man ssh and
> > man scp but cannot quite see an easy way of doing this!
>
> > Anyone care to help?
>
> > TIA
>
> > Tony
>
> Well, if you must write a "perl" prog then comp.unix.shell is probably
> the wrong pace to ask...
>
> In sh
>
> #!/bin/sh
> CF='/the/full/name/of/the/config/file'
> scp "$CF" remote_host:"$CF"
> ssh remote_host '/the/path/to/the/restarter/script'
>
> A trivial translation to perl would be something like (untested)
>
> #!/usr/bin/perl -w
> $CF='/the/full/name/of/the/config/file';
> print `scp "$CF" remote_host:"$CF"`';
> print `ssh remote_host '/the/path/to/the/restarter/script'`;
>
> This is not exactly a good use of perl!- Hide quoted text -
>
> - Show quoted text -
Thanks!
Iguess I misspoke - the perl prog is to create the config files - the
ssh/scp is to transfer the files thus produced and twiddle the
application so it uses the new config.
When I invoke scp "$CF" remote_host:"$CF", this will need a password
entering by hand methinks.
(I need to put this in a cronjob BTW)
How can I get round that? There is no -passord option passable on
commanline I notice..
TIA
Re: copy config files from one box to another
am 27.09.2007 07:40:49 von Icarus Sparry
On Wed, 26 Sep 2007 14:28:44 -0700, ton de w wrote:
> On 26 Sep, 13:09, Icarus Sparry wrote:
>> On Wed, 26 Sep 2007 02:51:27 -0700, ton de w wrote:
>> > Hello,
>> > I have a small but urgent programming task to attend to. Must write a
>> > perl prog, on redhat AS 3.8 to grab a table from a remote db and
>> > create some (config) files - no problem. These config files need to
>> > be fed to an application on another redhat AS 3.8 box. So two
>> > subtasks, transfer config files across and restart app so the app
>> > reads the config files.
>>
>> > There are identical non-root users on both boxes. And ssh, which I
>> > suppose is the only way to go, is configured as standard. I can
>> > restart the app with a local shell script no problem. I have done a
>> > man ssh and man scp but cannot quite see an easy way of doing this!
>>
>> > Anyone care to help?
>>
>> > TIA
>>
>> > Tony
>>
>> Well, if you must write a "perl" prog then comp.unix.shell is probably
>> the wrong pace to ask...
>>
>> In sh
>>
>> #!/bin/sh
>> CF='/the/full/name/of/the/config/file' scp "$CF" remote_host:"$CF"
>> ssh remote_host '/the/path/to/the/restarter/script'
>>
>> A trivial translation to perl would be something like (untested)
>>
>> #!/usr/bin/perl -w
>> $CF='/the/full/name/of/the/config/file'; print `scp "$CF"
>> remote_host:"$CF"`'; print `ssh remote_host
>> '/the/path/to/the/restarter/script'`;
>>
>> This is not exactly a good use of perl!- Hide quoted text -
>>
>> - Show quoted text -
> Thanks!
> Iguess I misspoke - the perl prog is to create the config files - the
> ssh/scp is to transfer the files thus produced and twiddle the
> application so it uses the new config.
>
> When I invoke scp "$CF" remote_host:"$CF", this will need a password
> entering by hand methinks.
> (I need to put this in a cronjob BTW) How can I get round that? There is
> no -passord option passable on commanline I notice..
> TIA
ssh and scp can avoid needing passwords by setting up keys.
On the local host run
ssh-keygen -t rsa
and hit return to any questions it may ask. This should create two files
in ~/.ssh, called id_rsa and id_rsa.pub (read the manual page to the
program ssh-keygen of course).
On "remote_host" make sure there is a directory ~/.ssh, with permissions
rwx------ (use "cd ; mkdir .ssh ; chmod 700 .ssh" and ignore most errors
about the directory already existing).
Copy the id_rsa.pub from the local host to "remote_host", and append it
to a file called ~/.ssh/authorized_keys2 (if the file does not exist then
just use "touch" to create it).
Now you should be able to use ssh and scp from the local host to
"remote_host" without a password. This should work from within cron as
well.
The filenames are important, as are the permissions. You may need to run
"chmod g-w ~" if you are on a redhat machine, to remove write permission
to your home directory from other members of your group.