Top-Themen

AppleEntwicklungHardwareInternetLinuxMicrosoftMultimediaNetzwerkeOff TopicSicherheitSonstige SystemeVirtualisierungWeiterbildungZusammenarbeit

Aktuelle Themen

Administrator.de FeedbackApache ServerAppleAssemblerAudioAusbildungAuslandBackupBasicBatch & ShellBenchmarksBibliotheken & ToolkitsBlogsCloud-DiensteClusterCMSCPU, RAM, MainboardsCSSC und C++DatenbankenDatenschutzDebianDigitiales FernsehenDNSDrucker und ScannerDSL, VDSLE-BooksE-BusinessE-MailEntwicklungErkennung und -AbwehrExchange ServerFestplatten, SSD, RaidFirewallFlatratesGoogle AndroidGrafikGrafikkarten & MonitoreGroupwareHardwareHosting & HousingHTMLHumor (lol)Hyper-VIconsIDE & EditorenInformationsdiensteInstallationInstant MessagingInternetInternet DomäneniOSISDN & AnaloganschlüsseiTunesJavaJavaScriptKiXtartKVMLAN, WAN, WirelessLinuxLinux DesktopLinux NetzwerkLinux ToolsLinux UserverwaltungLizenzierungMac OS XMicrosoftMicrosoft OfficeMikroTik RouterOSMonitoringMultimediaMultimedia & ZubehörNetzwerkeNetzwerkgrundlagenNetzwerkmanagementNetzwerkprotokolleNotebook & ZubehörNovell NetwareOff TopicOpenOffice, LibreOfficeOutlook & MailPapierkorbPascal und DelphiPeripheriegerätePerlPHPPythonRechtliche FragenRedHat, CentOS, FedoraRouter & RoutingSambaSAN, NAS, DASSchriftartenSchulung & TrainingSEOServerServer-HardwareSicherheitSicherheits-ToolsSicherheitsgrundlagenSolarisSonstige SystemeSoziale NetzwerkeSpeicherkartenStudentenjobs & PraktikumSuche ProjektpartnerSuseSwitche und HubsTipps & TricksTK-Netze & GeräteUbuntuUMTS, EDGE & GPRSUtilitiesVB for ApplicationsVerschlüsselung & ZertifikateVideo & StreamingViren und TrojanerVirtualisierungVisual StudioVmwareVoice over IPWebbrowserWebentwicklungWeiterbildungWindows 7Windows 8Windows 10Windows InstallationWindows MobileWindows NetzwerkWindows ServerWindows SystemdateienWindows ToolsWindows UpdateWindows UserverwaltungWindows VistaWindows XPXenserverXMLZusammenarbeit

Script sagt bei der Ausführung call ist syntaktisch an dieser Stelle nicht verarbeitbar.

Frage Entwicklung

Mitglied: nEmEsIs

nEmEsIs (Level 2) - Jetzt verbinden

20.07.2011 um 10:44 Uhr, 4013 Aufrufe, 2 Kommentare

Hi

Ich habe ein Problem mit einem Script, das einen ESXi herrunterfahren soll.

Es kommt immer "call" ist syntaktisch an dieser Stelle nicht verarbeitbar.

könnte mir da vll. jemand helfen.
Es besteht aus 2 Scripten.

1) Script
01.
@echo off 
02.
c:\scripts\esxi\shutdown [Hosetname oder IP] [Benutzer] [Passwort]  
03.
 

Hier das Script:

01.
@echo off 
02.
REM 
03.
REM *** ESXi Shutdown Script for use with free-licensed ESXi *** 
04.
REM 
05.
REM Primarily designed to shutdown an ESXi server under UPS management software 
06.
REM control, i.e. APC PowerChute. 
07.
REM 
08.
REM Performs a graceful ESXi shutdown - note that the server will ultimately 
09.
REM be powered off after VMs are suspended or shutdown, depending on their 
10.
REM configuration.  As a result, when utility power is restored, the host 
11.
REM *will not restart* itself (unless the UPS battery was completely 
12.
REM depleted and the server BIOS was appropriately configured). 
13.
REM 
14.
REM 
15.
REM Written by James Pearce (vmware communities user ID J1mbo 
16.
REM (http://communities.vmware.com/people/J1mbo?view=profile). 
17.
REM 
18.
REM Version 4 (being for use with ESXi 4) 
19.
REM - tested against ESXi 4 U1 from a Windows 2003 VM 
20.
REM - completed 09-Dec-09 
21.
REM 
22.
REM Usage: Shutdown.bat [hostname] [username] [password] 
23.
REM 
24.
REM [hostname] must be valid DNS name or an IP address 
25.
REM [username] is a user with shutdown rights, i.e. root 
26.
REM [password] is as used to connect to vSphere Client with the specificed 
27.
REM            username. 
28.
REM 
29.
REM Usage is logged to shutdown.log, stored in the same directory as the script. 
30.
REM 
31.
REM Depends on supporting text files: 
32.
REM 
33.
REM - open-1.txt         - Establishes the session, part 1. 
34.
REM - open-2.txt         - Establishes the session, part 2. 
35.
REM 
36.
REM - auth-1.txt         - Authentication request, part 1. 
37.
REM - auth-2.txt         - Authentication request, part 2. 
38.
REM - auth-3.txt         - Authentication request, part 3. 
39.
REM 
40.
REM - shutdown-1.txt     - Shutdown request, part 1. 
41.
REM - shutdown-2.txt     - Shutdown request, part 2. 
42.
REM - shutdown-3.txt     - Shutdown request, part 3. 
43.
REM 
44.
REM 
45.
REM IMPORTANT: DEPENDS ON NMAP "NCAT" UTILITY BEING PRESENT AND ACCESSIBLE IN THE 
46.
REM DEFAULT SEARCH PATH. 
47.
REM 
48.
REM Free disrtibution and use permitted - but entirely at your own risk!! 
49.
REM 
50.
REM If you find it useful commerically, a bottle of ale would always be 
51.
REM welcome :) 
52.
REM 
53.
 
54.
 
55.
REM First ensure in correct directory as APC software might not. 
56.
REM 
57.
REM These commands change the drive and directory to where the batch file is stored, 
58.
REM for example if it's at C:\ESXI\SHUTDOWN.BAT these lines become "C:" then 
59.
REM "cd \esxi\" 
60.
 
61.
%~d0 
62.
cd %~dp0 
63.
 
64.
 
65.
REM Log the use of the script 
66.
call :WriteLog "System shutdown called: %date% %time%" 
67.
 
68.
 
69.
REM Check paramters were passed in: 
70.
If %1a==a goto :ArgumentError 
71.
If %2a==a goto :ArgumentError 
72.
If %3a==a goto :ArgumentError 
73.
call :CheckHost %1 
74.
if not %hostconnectres%==found Goto :CleanUp 
75.
 
76.
 
77.
REM Found and could ping the host, OK to attempt the shutdown. 
78.
 
79.
 
80.
REM Store specified hostname or IP in file to enable the assembly of the HTTP requests. 
81.
Echo Host: %1:443 >shutdown-host.txt 
82.
set shutdown-host=%1 
83.
 
84.
 
85.
REM Compute length of auth frame data and write out temp files... 
86.
call :GetAuthLength %2 %3 
87.
Echo Content-Length: %content_len% > content-len.txt 
88.
 
89.
 
90.
REM Now assemble the files. 
91.
copy open-1.txt + shutdown-host.txt + open-2.txt open.txt > NUL 
92.
copy auth-1.txt + shutdown-host.txt + content-len.txt + auth-2.txt authenticate.txt > NUL 
93.
Echo       ^<userName^>%2^</userName^>>> authenticate.txt 
94.
Echo       ^<password^>%3^</password^>>> authenticate.txt 
95.
copy authenticate.txt + auth-3.txt authenticate.txt > NUL 
96.
 
97.
 
98.
 
99.
REM Announce our presence, so that the ESXi server will expect our authentication 
100.
REM attempt. 
101.
Echo Connecting... 
102.
ncat -C -i 2s --ssl %shutdown-host% 443 < open.txt > open-res.txt 
103.
 
104.
REM Check that response was HTTP/1.1 200 OK: 
105.
call :GetResponse open-res.txt 
106.
if not %httpretcode%==200 Goto :ServerNotResponding 
107.
 
108.
 
109.
REM next, an authentication attempt which will produce a session key: 
110.
Echo Authenticating... 
111.
ncat -C -i 2s --ssl %shutdown-host% 443 < authenticate.txt > auth-resp.txt 
112.
 
113.
REM Check that response was HTTP/1.1 200 OK: 
114.
call :GetResponse auth-resp.txt 
115.
if not %httpretcode%==200 Goto :AuthenticationError 
116.
 
117.
 
118.
Echo Creating host shutdown task... 
119.
 
120.
REM Find the key, and insert it in pre-formed request split at appropriate position... 
121.
find "vmware_soap_session" auth-resp.txt > auth-key.txt 
122.
for /f "skip=2 tokens=1,2,3,4* delims==;" %%i in (auth-key.txt) do echo %%j > auth-key.txt 
123.
copy shutdown-1.txt + shutdown-host.txt + shutdown-2.txt + auth-key.txt + shutdown-3.txt shutdown.txt > NUL 
124.
 
125.
 
126.
REM Send completed request to the ESXi host: 
127.
 
128.
REM FOLLOWING NCAT... IS THE DANGER LINE - REM IT OUT FOR INITIAL TESTING AS IT *WILL* SHUTDOWN 
129.
REM THE SPECIFIED ESXI HOST IF AUTHENTICATION SUCCEEDED!! 
130.
 
131.
ncat -C -i 2s --ssl %shutdown-host% 443 < shutdown.txt > shutdown-resp.txt 
132.
 
133.
REM Check that response was HTTP/1.1 200 OK: 
134.
call :GetResponse shutdown-resp.txt 
135.
if not %httpretcode%==200 Goto :ShutdownError 
136.
 
137.
 
138.
REM Result was OK - Log this. 
139.
call :WriteLog "Server accepted shutdown request." 
140.
 
141.
 
142.
Goto :Cleanup 
143.
 
144.
 
145.
 
146.
REM -------------------------------------------------------------------------------- 
147.
REM - Supporting "sub-routines"                                                    - 
148.
REM -------------------------------------------------------------------------------- 
149.
 
150.
 
151.
 
152.
REM -------------------------------------------------------------------------------- 
153.
:ArgumentError 
154.
REM script was called without three parameters 
155.
Echo. 
156.
Echo Usage: Shutdown.bat [hostname] [username] [password] 
157.
Echo. 
158.
Echo [hostname] must be valid DNS name or an IP address 
159.
Echo [username] is a user with shutdown rights, i.e. root 
160.
Echo [password] is as used to connect to vSphere Client with the specificed 
161.
Echo            username. 
162.
Echo. 
163.
Echo Usage is logged to shutdown.log, stored in the same directory as the script. 
164.
Echo. 
165.
call :WriteLog "Missing parameter(s) - Usage: Shutdown.bat [hostname] [username] [password]" 
166.
Goto :End  
167.
 
168.
 
169.
 
170.
REM -------------------------------------------------------------------------------- 
171.
:CheckHost 
172.
REM Routine to determine if host is valid and online.  Performs a Ping test. 
173.
 
174.
REM Clear out any old files: 
175.
if exist test-connect.txt del test-connect.txt 
176.
if exist not-found.txt del not-found.txt 
177.
if exist found.txt del found.txt 
178.
if exist time-out.txt del time-out.txt 
179.
set hostconnectres= 
180.
 
181.
REM Ping the host - first ping is desregarded as may time out due to arp delay: 
182.
ping %1 -n 1 > NUL 
183.
ping %1 -n 1 > test-connect.txt 
184.
 
185.
REM Analyse the results and set environment variable hostconnectres: 
186.
find "could not find host" test-connect.txt > not-found.txt 
187.
find "Lost = 0" test-connect.txt > found.txt 
188.
find "Lost = 1" test-connect.txt > time-out.txt 
189.
for /f "skip=2 tokens=*" %%i in (not-found.txt) do if not a%%i==a set hostconnectres=cant_resolve 
190.
for /f "skip=2 tokens=*" %%i in (found.txt) do if not a%%i==a set hostconnectres=found 
191.
for /f "skip=2 tokens=*" %%i in (time-out.txt) do if not a%%i==a set hostconnectres=time-out 
192.
 
193.
REM Clear-up temp files: 
194.
if exist test-connect.txt del test-connect.txt 
195.
if exist not-found.txt del not-found.txt 
196.
if exist found.txt del found.txt 
197.
if exist time-out.txt del time-out.txt 
198.
 
199.
REM Write out results to the log: 
200.
if %hostconnectres%==cant_resolve call :WriteLog "Could not resolve specified hostname %1." 
201.
if %hostconnectres%==time-out call :WriteLog "Could not reach specified host %1: time-out." 
202.
 
203.
Goto :End 
204.
 
205.
 
206.
 
207.
REM -------------------------------------------------------------------------------- 
208.
:GetAuthLength 
209.
REM Returns in environment variable content_len the length of the auth frame, based 
210.
REM on the username in %1, password in %2 + 467. 
211.
echo %1%2 > tempstr.txt 
212.
for %%a in (tempstr.txt) do set /a len=%%~za 
213.
set /a len -=3 
214.
set /a content_len = %len% + 467 
215.
if exist tempstr.txt del tempstr.txt 
216.
Goto :End 
217.
 
218.
 
219.
REM -------------------------------------------------------------------------------- 
220.
:ServerNotResponding 
221.
call :WriteLog "ESXi Server did not accept connection attempt:" 
222.
call :WriteLog "Return code was %httpretcode%." 
223.
Goto :Cleanup 
224.
 
225.
 
226.
 
227.
 
228.
REM -------------------------------------------------------------------------------- 
229.
:AuthenticationError 
230.
call :WriteLog "ESXi authentication did not succeed:" 
231.
call :WriteLog "Return code was %httpretcode%." 
232.
Goto :Cleanup 
233.
 
234.
 
235.
 
236.
 
237.
REM -------------------------------------------------------------------------------- 
238.
:ShutdownError 
239.
call :WriteLog "ESXi shutdown request failed:" 
240.
call :WriteLog "Return code was %httpretcode%." 
241.
Goto :Cleanup 
242.
 
243.
 
244.
 
245.
 
246.
REM -------------------------------------------------------------------------------- 
247.
:GetResponse 
248.
REM Stores the response code in return frame passed via a file specified as %1. 
249.
REM HTTP/1.1 response code (i.e. 200 for OK) is stored in %httpretcode% 
250.
set httpretcode=(no-response-from-server) 
251.
if exist response-tmp.txt del response-tmp.txt 
252.
find "HTTP/1.1" %1 > response-tmp.txt 
253.
for /f "skip=2 tokens=1,2* delims= " %%i in (response-tmp.txt) do set httpretcode=%%j 
254.
if exist response-tmp.txt del response-tmp.txt 
255.
Goto :End 
256.
 
257.
 
258.
 
259.
 
260.
REM -------------------------------------------------------------------------------- 
261.
:CleanUp 
262.
call :WriteLog "---------------------------------------------------------------------------" 
263.
REM Clear up temporary text files... 
264.
if exist shutdown-host.txt del shutdown-host.txt 
265.
if exist open.txt del open.txt 
266.
if exist authenticate.txt del authenticate.txt 
267.
if exist shutdown.txt del shutdown.txt 
268.
if exist open-res.txt del open-res.txt 
269.
if exist shutdown-resp.txt del shutdown-resp.txt 
270.
if exist auth-key.txt del auth-key.txt 
271.
if exist auth-resp.txt del auth-resp.txt 
272.
if exist response-tmp.txt del response-tmp.txt 
273.
Goto :End 
274.
 
275.
 
276.
 
277.
 
278.
REM -------------------------------------------------------------------------------- 
279.
:WriteLog 
280.
REM Appends the specified string to the log file and displays on screen. 
281.
echo %~1 
282.
echo %~1 >> shutdown.log 
283.
Goto :End 
284.
 
285.
 
286.
 
287.
 
288.
:End
MFG Nemesis

PS: das Script ist für eine APC Smart USV für den Kostenlosen ESXi
(Ich weiß offizell wird das nicht supportet)
Mitglied: AndreasHoster
20.07.2011 um 12:12 Uhr
Über welches call Kommando kommt er denn nicht? Da sind ja mehrere drin.
Ok, ich nehme an, Du hast keine Ahnung welches und auch keine Ahnung wie man es rausbekommt.

Also, Debugging for ...:
Als erstes, nimm mal den @echo off Befehl aus dem langen Skript raus und starte es mal in einer Kommandozeile.
Da sollte man dann eigentlich sehen, an welchem call er rausfliegt.

Und eventuell noch die Info, von welchem OS Du versuchst es auszuführen, dann muß man auch nicht soviel raten.
Bitte warten ..
Mitglied: nEmEsIs
20.07.2011 um 12:45 Uhr
Hi

Also OS ist derzeit Windows XP soll aber wenn es fuktioniert soll es auf Windows Server 2008 R2 laufen.

Welches call es ist probier ich jetzt aus.

Erstmal danke für deine Hilfe

MFG Nemesis
Bitte warten ..
Neuester Wissensbeitrag
Windows 10

Powershell 5 BSOD

(8)

Tipp von agowa338 zum Thema Windows 10 ...

Ähnliche Inhalte
Batch & Shell
Powershell-Script über Task Scheduler zeigt CMD während Ausführung (5)

Frage von DanielBodensee zum Thema Batch & Shell ...

Batch & Shell
gelöst PowerShell Script Move-Item nach x Tagen (5)

Frage von lupolo zum Thema Batch & Shell ...

VB for Applications
VBS Script zum versenden mehrerer Verknüpfungen zu Dateien per Lotus Notes

Frage von Sentinel87 zum Thema VB for Applications ...

Heiß diskutierte Inhalte
Microsoft
Ordner mit LW-Buchstaben versehen und benennen (21)

Frage von Xaero1982 zum Thema Microsoft ...

Netzwerkmanagement
gelöst Anregungen, kleiner Betrieb, IT-Umgebung (18)

Frage von Unwichtig zum Thema Netzwerkmanagement ...

Windows Update
Treiberinstallation durch Windows Update läßt sich nicht verhindern (17)

Frage von liquidbase zum Thema Windows Update ...