Jump to content

Run command with a Variable


ss18
 Share

Recommended Posts

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")
Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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}")
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...