Error : compilation error Expected ')'
-
Saturday, February 02, 2013 11:17 PM
My script does not want to complete, i've run out of idea to get it going anyone help will be greatly appreciated.
This is the error i do receive : Microsoft VBScript compilation error expected ')'
'ON ERROR RESUME NEXT Const ForReading = 1,ForAppending = 8 Set oShell = createobject ("wscript.shell") Set objDictionary = CreateObject("Scripting.Dictionary") Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFileSystem = CreateObject("Scripting.FileSystemObject") Set objTextFile = objFSO.OpenTextFile ("C:\IP.txt", ForReading) Set objShell = WScript.CreateObject("WScript.Shell") Set CH = Char(13) & Char(10) strLogFile = "C:\" & Split(WScript.ScriptName, ".")(0) & ".log" i = 0 Do Until objTextFile.AtEndOfStream strNextLine = objTextFile.ReadLine objDictionary.Add i, strNextLine i = i + 1 job=objShell.Run("cmd /c plink.exe -v -telnet -P 23 " & strNextLine & " & "USER username password" & CR & "vts info" & CR & "bye" & CR & " >>log.txt", 0, TRUE) LoopThanks
OC
All Replies
-
Saturday, February 02, 2013 11:33 PM
Look closely at thsi. Contemplate how and why it works then look at your code.
Set objFSO = CreateObject("Scripting.FileSystemObject") Set objTextFile = objFSO.OpenTextFile ("C:\IP.txt") Set objShell = WScript.CreateObject("WScript.Shell") i = 0 Do Until objTextFile.AtEndOfStream strNextLine = objTextFile.ReadLine i = i + 1 sCmd="cmd /c plink.exe -v -telnet -P 23 " _ & strNextLine _ & "USER username password" _ & vbCRLf & "vts info" _ & vbCrLf & "bye" & vbCrLf _ & " >>log.txt" WScript.Echo sCmd job=objShell.Run(cmd, 0, TRUE) Loop
¯\_(ツ)_/¯
- Edited by jrvMicrosoft Community Contributor Saturday, February 02, 2013 11:47 PM
-
Saturday, February 02, 2013 11:45 PMUnfortunately the code you posted give this error: Microsoft VBScript runtime error: Object Required: objDictionary
-
Saturday, February 02, 2013 11:48 PMSorry - I thought I deleted that line. I fixed it so try again.
¯\_(ツ)_/¯
-
Saturday, February 02, 2013 11:53 PMDo not understand i am getting this now : C:\script.vbs(15, 9) Microsoft VBScript runtime error: Invalid procedure call or argument
-
Sunday, February 03, 2013 12:27 AMModerator
In the last line of your code the quotes don't match up, probably because you have too many "&" characters. The final closing ")" is actually part of a quoted string and is not recognized.
Richard Mueller - MVP Directory Services
-
Sunday, February 03, 2013 12:51 AMthx for the reply Richard is there a way to circumvent this ? Sorry if i sound a bit needy this is my first attempt at scripting vbs...
- Edited by Loonatic22 Sunday, February 03, 2013 12:54 AM
-
Sunday, February 03, 2013 1:06 AMModerator
Perhaps replace this fragment of the objShell.Run statement:
& strNextLine & " & "USER username password
-----
with this:
& strNextLine & "USER username password"
-----
I removed one extraneous "&" character and one extra double quote. Notice in the first case (and in the code you posted) that the colorization of this statement is screwed up. Strings are supposed to be green in the forum editor, and in my HTML code I color strings in red. The extra quote means that the colorization process gets confused, so the final ")" character is part of a string and not recognized as part of the statement. Hence the error message.
jv's suggestion to assign the statement to a variable, sCmd in his example, is excellent. Then you can echo the statement to the command console to see if it looks correct. Later you can use the variable in the objShell.Run statement. I have not done this for your statement, and I have no idea if the statement is valid. However, the extra quote (and extra "&") are clearly wrong.
Richard Mueller - MVP Directory Services
- Marked As Answer by Bartek BielawskiModerator Monday, April 08, 2013 10:44 AM
-
Sunday, February 03, 2013 1:06 AM
thx for the reply Richard is there a way to circumvent this ? Sorry if i sound a bit needy this is my first attempt at scripting vbs...
Back now. Yes - that is where you problem is.
\
¯\_(ツ)_/¯
-
Sunday, February 03, 2013 1:09 AM
Unfortunately your scrip makes no sense.
You cannot sent lines of text to a program by just adding them to the run line the crlf in between.
Try contacting the vendor for instructions.
¯\_(ツ)_/¯

