Restart machine in different OS paltform

A

andyng.hk

Hi:
I need to write a script which need to restart machine for AIX
,windows and linux.
What is the easier way to do that in perl?

Thanks
 
G

George

Hi:
I need to write a script which need to restart machine for...
[snip]

...windows

if your Windows happens to be Windows NT, see
Win32::InitiateSystemShutdown.
I have typed in "perldoc win32" for ActiveState Perl and after a couple
of pages I found:

Win32::InitiateSystemShutdown
(MACHINE, MESSAGE, TIMEOUT, FORCECLOSE, REBOOT)

[EXT] Shutsdown the specified MACHINE, notifying users with the
supplied MESSAGE, within the specified TIMEOUT interval. Forces
closing of all documents without prompting the user if FORCECLOSE
is
true, and reboots the machine if REBOOT is true. This function
works
only on WinNT.
 
V

Vipin Nair

Hello George,

Could you please give an example of usage.
How to specify MACHINE, is it Ip address?
Is MESSAGE, quoted words
TIMEOUT, is this time in milliseconds
FORCECLOSE, can we use hard coded values
REBOOT

Win32::InitiateSystemShutdown (xxx.xxx.xx.xxx, "Viel Spass", 10 , 1, 1)
(xxx is ip address)
but it was giving error as:

The filename, directory name, or volume label syntax is incorrect.

Regards,
Vipin
 
B

Brian Wakem

Hi:
I need to write a script which need to restart machine for AIX
,windows and linux.
What is the easier way to do that in perl?

Thanks


On linux: `shutdown -r now`
 
D

Dave

Vipin Nair said:
Hello George,

Could you please give an example of usage.
How to specify MACHINE, is it Ip address?
Is MESSAGE, quoted words
TIMEOUT, is this time in milliseconds
FORCECLOSE, can we use hard coded values
REBOOT

Win32::InitiateSystemShutdown (xxx.xxx.xx.xxx, "Viel Spass", 10 , 1, 1)
(xxx is ip address)
but it was giving error as:

The filename, directory name, or volume label syntax is incorrect.

Regards,
Vipin

lpMachineName
[in] Pointer to the null-terminated string that specifies the network name
of the computer to shut down. If lpMachineName is NULL or an empty string,
the function shuts down the local computer.
http://windowssdk.msdn.microsoft.co...n-us/Shutdown/base/initiatesystemshutdown.asp
 
A

andyng.hk

Thanks for the replies, what if i don't know whether the machine is
linux, AIX or windows? we need to have 1 script applied regionally to
different OS and machine...
 
T

Tad McClellan

what if i don't know whether the machine is
linux, AIX or windows?


perl -le 'print "my OS is $^O"'

we need to have 1 script applied regionally to
different OS and machine...


if ( $^O eq 'linux' )
{ linux_restart() }
elsif ( $^O eq 'MSWin32' )
{ windows_restart() }
...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,183
Messages
2,570,968
Members
47,524
Latest member
ecomwebdesign

Latest Threads

Top