Leser: 23
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/perl
use Expect;
$text = "TestShutdown";
$user = "test_admin";
$pw = "admin12345";
#--- CONFIGURATION -----------------------------------------------------------#
$cmd = 'runas /user:$user "shutdown -s"';
$prompt = "[Pp]assword";
#--- START RUNAS LOGIN SEQUENCE ;;! ----------------------------------------------#
$exp = new Expect();
$exp->raw_pty(1);
$exp->spawn($cmd) or die "spawn failed";
#--- LOGIN AND INTERACT ! ----------------------------------------------------#
$exp->expect(10000, [ $prompt => sub { $_[0]->send("$pw\n"); } ]);
$exp->interact();
1 2 3 4 5 6
#!/usr/bin/env perl use strict; use warnings; my $eingabe = <STDIN>; print "Eingegeben wurde: \'$eingabe\'\n";