0

While doing this it gives me an error:

Traceback (most recent call last):
     File "C:\Users\ibrahim\Desktop\app.py", line 23, in <module>
       a=input("enter the ipaddress")
     File "<string>", line 1
       192.168.1.1
               ^
   SyntaxError: invalid syntax

Here's my code:

import os
a=input("enter the ipaddress")
os.system('a')


it does not work help me out !!!
Maxime Lorant
  • 34,607
  • 19
  • 87
  • 97

2 Answers2

0

You are passing the string 'a' not the variable a, take the quotation marks off:

import os
a=input("enter the ipaddress")
os.system(a)
Preston
  • 2,543
  • 1
  • 17
  • 26
  • Traceback (most recent call last): File "C:\Users\ibrahim\Desktop\app.py", line 22, in z=input("") File "", line 1 192.168.1.1 ^ SyntaxError: invalid syntax – ibrahim haleem khan Jan 02 '14 at 17:18
0

I would suggest to use hostname instead of a, because as you will run some commands after ssh to some device, the input should get assigned as hostname - ssh.connect(hostname, port=22, username=x, password=y). So the suggested code is -

import os
hostname=input("enter the ipaddress")
os.system(hostname)
legoscia
  • 39,593
  • 22
  • 116
  • 167