Koozali.org: home of the SME Server

Quick shutdown

Gert

Quick shutdown
« on: March 03, 2002, 05:12:25 PM »
Is it posible to shut down e-smith from my windows client
whitout using the server-manage.
 
i am planning to use a script to shutdown both windows and e-smith

Dan G.

Re: Quick shutdown
« Reply #1 on: March 03, 2002, 06:09:44 PM »
....and now for something completely different...

You _may_ be able to accomplish what you are trying to do with an HTTP bot.  Have a look at http://www.davecentral.com/projects/internetrobot/, and other projects at davecentral.com.  You would need to figure out what strings to send to the e-smith-manager, but it might just work :)

Dan

Michael

Re: Quick shutdown
« Reply #2 on: March 03, 2002, 11:38:04 PM »
Before you're going to pay for such a program get the "Perl Cookbook" instead, download ActivePerl for free and copy some Perl script out of the book to do the job.

Les Mikesell

Re: Quick shutdown
« Reply #3 on: March 05, 2002, 12:12:21 AM »
A command line ssh client is a good way to script things remotely.  The 'plink' tool that comes with the free putty.exe should work, or if you want something more unix-like you can install the tools from www.cygnus.com.   Running '/sbin/shutdown -h now'  on the server should stop it.

Gert

Re: Quick shutdown
« Reply #4 on: March 05, 2002, 12:29:41 PM »
Do you know what script to copy ?

Michael

Re: Quick shutdown
« Reply #5 on: March 05, 2002, 12:36:38 PM »
Assuming you're talking to me :-). Have a look at "20.2. Automating Form Submission" in the "Web Automation" chapter.

Gert

Re: Quick shutdown
« Reply #6 on: March 05, 2002, 01:46:12 PM »
www.cygnus.com get me to www.redhat.com
can't find anything there.

I downloaded putty.exe and plink but how exacly can i shut down e-smith whit it ?

Gert

Re: Quick shutdown
« Reply #7 on: March 05, 2002, 02:34:08 PM »
Got it :-)

Somthing like.
****************************************************
use LWP::Simple;
use URI::URL;

my $url = url('http://www.perl.com/cgi-bin/cpan_mod');
$url->query_form(module => 'DB_File', readme => 1);
$content = get($url);
If you're using the POST method, create your own user agent and encode the content appropriately:

use HTTP::Request::Common qw(POST);
use LWP::UserAgent;

$ua = LWP::UserAgent->new();
my $req = POST 'http://www.perl.com/cgi-bin/cpan_mod',
               [ module => 'DB_File', readme => 1 ];
$content = $ua->request($req)->as_string;
*****************************************************
How do i get further ?
My shutdown site is at: http://Http://Linux-server/server-manager/cgi-bin/reboot

please help me, i am very new in script and programming.

Michael

Re: Quick shutdown
« Reply #8 on: March 05, 2002, 02:49:42 PM »
Gert

I do not try this myself, as I don't want to shut my box down right now. But have a try with the following lines:

my $url = url('http://myE-SmithBox.mydomain.net/server-manager/cgi-bin/reboot');
$url->query_form(function => 'shutdown', action => 'Perform', state => 'perform');
$content = get($url);

Gert

Re: Quick shutdown
« Reply #9 on: March 05, 2002, 10:23:36 PM »
Well, it's allmost there.(i hope)
i made a perl script like this:
***************************************
use LWP::Simple;
use URI::URL;

my $url = url(http://Linux-server/server-manager/cgi-bin/reboot);
$url->query_form(module => shutdown, action => Perform, state =>perform);

$content = get($url);
***************************************
It is opening and closing a black box very quickly.
It is connecting the right ip adresse but nothing seams to happend.
i don't get any errors.

im lost, please help

gc

Les Mikesell

Re: Quick shutdown
« Reply #10 on: March 06, 2002, 09:30:39 AM »
> www.cygnus.com get me to www.redhat.com
> can't find anything there.

Oops, the site is http://www.cygwin.com these days.  Those tools may be overkill if you don't want most of the unix environment on your windows box.

> I downloaded putty.exe and plink but how exacly can i shut
> down e-smith whit it ?

First try it interactively to make sure the ssh service is enabled on the server. Use putty to connect to the server using ssh.  Log in as root - if you want to shut down at that point the command 'reboot -h' should work, or 'shutdown -h now'.   Then in a script you can use plink to send the same command.

Gert

Re: Quick shutdown
« Reply #11 on: March 06, 2002, 01:01:39 PM »
Att: Les

OK, i got Putty to connect to my server, but it wont accept my root password.

What can be wrong ?

gc

Paul Lakra

Re: Quick shutdown
« Reply #12 on: March 06, 2002, 01:56:59 PM »
Make sure you use 'admin' as the user name. This one caught me out.

Norrie

Re: Quick shutdown
« Reply #13 on: March 06, 2002, 02:16:28 PM »
Hi folks,

I tried the plink method yesterday.  I got as far as getting plink to automatically log into the server as root but I still have to supply the (root) password.  Paul, why admin as the username?  I've never had trouble logging into e-smith as root with putty.

Anyway.  I got stuck when trying to add the public key info to e-smith to enable non-interactive log ins with putty / plink.  (See the putty site)

Anyone help?

NTB
8o)

Paul Lakra

Re: Quick shutdown
« Reply #14 on: March 06, 2002, 03:02:59 PM »
Sorry - I jumped in a bit too quickly here without reading what went before. I have not played with my e-smith box for a few weeks but I remember there was some problem logging in as root. I have not got my notes with me here. If this thread is still running later I'll check when I get home.