Jump to content

quotation handling


Recommended Posts

Hi

I'm having this line and I could not succeed to make it run because it is interpeted as splitted:

ControlSend ($handle,"","", 'plink -ssh -v -l ' & $user1 & ' -pw ' & $pass1 & " " & $ip1 & "{Enter}")

Please help and explain.

Thank you

Link to comment
Share on other sites

Interpreted as split by Auto IT or another program? Syntax-wise, it's OK; maybe one of the variables has a character that the your program sees as unreadable (whitespace or unicode)

Edited by Varian
Link to comment
Share on other sites

I don't have any issue with your syntax as written. See what happens with this(it's copied & pasted from your line so it's not a fat-finger issue by you)

Local $handle, $user1 = @username, $pass1 = 'password', $ip1 = @IPAddress1

Run('notepad.exe')
If Not winWait('[REGEXPTITLE:(?i)Untitled|(?i)Notepad]', '', 5) Then Exit
$handle = WinGetHandle('[REGEXPTITLE:(?i)Untitled|(?i)Notepad]', '')
ControlSend($handle,"","", 'plink -ssh -v -l ' & $user1 & ' -pw ' & $pass1 & " " & $ip1 & "{Enter}")

Zedna's just quoted it so that it would output (as an example):

plink -ssh -v -l "Administrator" -pw "password" "10.10.25.53"

Edited by Varian
Link to comment
Share on other sites

I found where the problem is.

I'm declaring variables by FileRead. For example:

;$user1 = FileRead ("userlogon.txt")

It is OK if I'm using:

$user1 = "root"

This leads me at your previous post ,Varian

maybe one of the variables has a character that the your program sees as unreadable (whitespace or unicode)
. How can be this "fixed"?

I have another question. Can you tell me what is the meaning of (?i)

in this line:

If Not winWait('[REGEXPTITLE:(?i)Untitled|(?i)Notepad]', '', 5) Then Exit

And what does [last] means ? I saw this in another thread posted here on the forum :

ControlSend("[last]", "", "", $variable & "{Enter}")

Thank you very much for your support.

Edited by mentosan
Link to comment
Share on other sites

You need to show us what's being retrieved from the "userlogon.txt" file.

If the file is multiline, you may need to use FileReadLine, if it has embedded control characters (a StringLen() test would show that) you may need to put it through a StringStripWS() statement (or manually remove the characters). If it has embedded quotes, you'd probably want to remove them.

From the help file under Regular Expressions, or StringregExp:

(?i) = case-insensitivity

So, it matches on "untitled" or "Untitled" or "notepad" or "nOtEpAd", etc, regardless of case.

From the helpfile under "Window titles and text":

[LAST] - Last window used in a previous AutoIt command

Edited by Spiff59
Link to comment
Share on other sites

What about this line

ControlSend ($handle,'','', @ScriptDir & "\bin\plink" & '{Enter}')

I'm getting error because @ScriptDir would be on my Desktop so the path is "C:\Documents and Settings\Administrator\Desktop\Script".

How can I insert @ScriptDir into quotas ? I cannot manage to make it work. :|

The return of the command is "C:\Documents" and I need "C:\Documents and Settings".

Edited by mentosan
Link to comment
Share on other sites

What about this line

ControlSend ($handle,'','', @ScriptDir & "\bin\plink" & '{Enter}')

I'm getting error because @ScriptDir would be on my Desktop so the path is "C:\Documents and Settings\Administrator\Desktop\Script".

How can I insert @ScriptDir into quotas ? I cannot manage to make it work. :|

The return of the command is "C:\Documents" and I need "C:\Documents and Settings".

ControlSend ($handle,'','', '"' & @ScriptDir & '\bin\plink"' & '{Enter}')
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...