Thread PHP Skript Konvertieren in Perl (10 answers)
Opened by segler at 2010-06-17 16:08

segler
 2010-06-17 16:08
#138434 #138434
User since
2010-06-17
6 Artikel
BenutzerIn
[default_avatar]
Hallo Forum,

ich habe folgendes Problem. Ich habe ein PHP Skript mit dem ich einen WLAN Benutzer auf einem Switch anlegen kann. Dieses Skript würde ich gerne in ein Perl Skript umwandeln. Leider habe ich keine Ahnung, wie ich das anstellen kann/muss.

Kann mir einer von Euch einen Tipp geben?


Freue mich über jede Antwort
Segler

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
require_once("soapapi-inc.php");

// connection settings
define("SOAPAPI_PROTO", "http");
define("SOAPAPI_HOST", "172.16.8.15");
define("SOAPAPI_PORT", "448");
define("SOAPAPI_FORMAT", "%s://%s:%d/SOAP");
define("SOAPAPI_WSDL_FILE", "../soapapi.wsdl");

// defining some useful constants.
define("REQUIRED_API_VERSION", "2.6.0");
define("VAP_GLOBAL", "Global");
define("EQUIPMENT_ID", "EQPT_1");
define("COUNTRY_CODE", "CANADA");

// clearing WSDL cache in the case the WSDL
// file would have changed.
SoapApi::ClearWSDLCache();

try {
// creating target URL
$url = sprintf(SOAPAPI_FORMAT, SOAPAPI_PROTO, SOAPAPI_HOST, SOAPAPI_PORT);
//echo "connecting to " . SOAPAPI_HOST . " using " . SOAPAPI_PROTO . "\n";

if (strcmp("http", SOAPAPI_PROTO) == 0) {
$c = new SoapApi(SOAPAPI_WSDL_FILE, array( 'location' => $url ,
'proxy_host' => SOAPAPI_HOST,
'proxy_port' => SOAPAPI_PORT
)
);
} else if (strcmp("https", SOAPAPI_PROTO) == 0) {
// creating a new SoapApi object. A fault will be raised if unsucessul.
$c = new SoapApi(SOAPAPI_WSDL_FILE, array( 'location' => $url,
'local_cert' => SOAPAPI_CLIENT_CERT,
'passphrase' => SOAPAPI_CLIENT_CERT_PASSPHRASE
)
);
} else {
echo "unknown protocol <" . SOAPAPI_PROTO . ">\n";
exit(1);
}

//echo "Retrieving SOAP API version...\n";
$rc = $c->soapGetSOAPVersion();
if (strcmp($rc->version, REQUIRED_API_VERSION) != 0) {
printf("Incorrect SOAP API version found: <%s> - expecting <%s>\n",
$rc->version,
REQUIRED_API_VERSION
);
exit(1);
}

printf("<H3>AddUserAccount</H3>");
$rc = $c->soapAddUserAccount("Test01", "123456", 1, 1);
printf("<br>");

printf("<H3>UpdateVirtualSCLocalUser</H3>");
$rc = $c->soapUpdateVirtualSCLocalUser("Internetzugang","Test01","123456",60,0,1);
printf("<br>");

exit;

} catch (SoapFault $fault) {
// displaying fault.
printf("<H1>Fehler im Skript!</H1><br>");
printf("string: <%s><br>", $fault->faultstring);
printf("code: <%s><br>", $fault->faultcode);
printf("actor: <%s><br>", $fault->error_message_prefix);
printf("detail: <%s><br>", $fault->userinfo);

// terminating and returning an error.
exit(1);
}

?>



Datei soap-inc.php
...
Code: (dl )
1
2
3
4
5
6
7
    function soapAddUserAccount($username, $password, $activeState, $accessControlledState)
{
// Add a new user account.
$rc = $this->AddUserAccount(array("username" => $username, "password" => $password, "activeState" => $activeState, "accessControlledState" => $accessControlledState));

return $rc;
}

...
Last edited: 2010-06-17 16:16:42 +0200 (CEST)

View full thread PHP Skript Konvertieren in Perl