Sign in to follow this  
Followers 0
mentosan

quotation handling

9 posts in this topic

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

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

@ Zedna: It is not ok. What is the synthax you've been using ? Each word must be quoted, even variables ?

@ Varian: by AutoIt.

Edited by mentosan

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

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

Share this post


Link to post
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}')

Share this post


Link to post
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
Sign in to follow this  
Followers 0