Sign in to follow this  
Followers 0
ss18

Run command with a Variable

11 posts in this topic

trying to add a variable to my script, and having no luck. the telnet window opens and say's it's trying to connect to $host, and not the IP address. when i replace the $host with the IP it works fine. Unless i'm defining it wrong, but it looked correct based on the example!

$host = "127.0.0.1"
Run ("telnet.exe $host")

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

By putting it inside the quotes, you made it a literal string instead of a variable. Try:

Run ("telnet.exe " & $host)

:)

Jos the speed typist beat me to it! ;)

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

thanks! i knew it had to be something simple ;)

Share this post


Link to post
Share on other sites

A antother possiblity:

Opt('ExpandVarStrings', 1)
$host = "127.0.0.1"
Run ("telnet.exe $host$")

Share this post


Link to post
Share on other sites

can you use variables with ControlSend? like

$host = "127.0.0.1"
$wintitle = "Telnet 127.0.0.1"

Run ("telnet.exe " & $host)

ControlSend ("$wintitle", "", "", "enable{ENTER}")

Share this post


Link to post
Share on other sites

can you use variables with ControlSend? like

$host = "127.0.0.1"
$wintitle = "Telnet 127.0.0.1"

Run ("telnet.exe " & $host)

ControlSend ("$wintitle", "", "", "enable{ENTER}")

Loose the double quotes around the variable name. Think you need to do a little reading in the helpfile first to pick some of the basics.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

yeah, i'm trying to read through it, making some progress on my own, but also hitting a few issues!

thanks for the help!

Share this post


Link to post
Share on other sites

while i'm reading more if anyone has any other help. the $wintitle works perfect, but it won't pass the $server IP, it just shows up at "$server".

$server = "192.168.200.1"
$host = "127.0.0.1"
$wintitle = "Telnet 127.0.0.1"

Run ("telnet.exe " & $host)

ControlSend ("$wintitle", "", "", "enable{ENTER}")
ControlSend ("$wintitle", "", "", "$server {ENTER}")

Share this post


Link to post
Share on other sites

got it, and i had to put ENTER on it's own line!

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