0

is there any way to put the variable posorprom inside the telnet command in python? Here is a peace of my code:

posorprom = prom

tn.write(b"ls /mnt/flash/prom | wc -l\n")

i want to put the variable posorprom inside the command, so i already tried this:

tn.write(b"ls /mnt/flash/" + posorprom + " | wc -l\n")

but it doesnt work. please help me.

Mario
  • 1
  • 1
  • For future questions please include the actual errors you get, copy-pasted (as text) in full and complete. "It doesn't work" is just not good enough. And please take some time to refresh [how to ask good questions](http://stackoverflow.com/help/how-to-ask), as well as [this question checklist](https://codeblog.jonskeet.uk/2012/11/24/stack-overflow-question-checklist/). – Some programmer dude Jan 27 '20 at 12:33
  • @Mario Aren't you interested in an answer anymore? – Nirostar Jan 27 '20 at 13:28
  • hello again, i used both answers but i stll have the problem – Mario Jan 27 '20 at 14:57

2 Answers2

0

Well you seem to concatenate different kinds of strings, since you use raw byte strings for one string, then all the strings must be that:

posorprom = b"prom"
tn.write(b"ls /mnt/flash/" + posorprom + b" | wc -l\n")
Some programmer dude
  • 400,186
  • 35
  • 402
  • 621
0

posorprom = prom does not set the variable posoprom to "prom", but to the value of the variable prom.

Try posorprom = "prom" instead.

posorprom = "prom" tn.write("ls /mnt/flash/" + posorprom + " | wc -l\n")

Nirostar
  • 189
  • 12