Quantcast
Channel: Rainmeter Forums
Viewing all articles
Browse latest Browse all 1538

Other Software & Customization • Re: Question about Script for Telnet/SSH/Python/Powershell

$
0
0
Based on your manual method, I assume TelNet is asking you the username and password for your modem / connection, right? If so, not sure that part is doable just by using a script or requires user interaction. Getting the result in a skin shouldn't be a problem if the output is direct, i.e. via a single command or set of commands where you'd specify the username and password as parameters (I suppose the delays could be part of such a potential script)...

If not, an AutoIt / AutoHotKey script might offer an alternative approach.
I have to enter a username and password to access the modem via telnet and ssh.

I don't understand where I'm going wrong but I couldn't get output as batch and ps.

I was able to get output with ps (powerscript) once and then it stopped working....

Code:

# Telnet bağlantısı başlatılıyor$telnet = New-Object System.Net.Sockets.TcpClient$telnet.Connect("192.168.2.1", 23)  # Telnet portu genellikle 23'tür$stream = $telnet.GetStream()$reader = New-Object System.IO.StreamReader($stream)$writer = New-Object System.IO.StreamWriter($stream)# Timeout ayarı$stream.ReadTimeout = 5000  # 5 saniye# Gecikmeler ve komutlarStart-Sleep -Seconds 3$writer.WriteLine("admin")$writer.Flush()Start-Sleep -Seconds 3$writer.WriteLine("*******")$writer.Flush()Start-Sleep -Seconds 2$writer.WriteLine("show interface Dsl0")$writer.Flush()Start-Sleep -Seconds 3$writer.WriteLine("exit")$writer.Flush()Start-Sleep -Seconds 1$writer.WriteLine("exit")$writer.Flush()# Çıktıyı oku ve bir dosyaya yaz$output = $reader.ReadToEnd()$output | Out-File "output.txt"# Bağlantıyı kapat$telnet.Close()

Statistics: Posted by tass_co — Today, 5:15 pm



Viewing all articles
Browse latest Browse all 1538

Trending Articles