S
S
shell_guy2021-12-13 11:52:30
Python
shell_guy, 2021-12-13 11:52:30

How to add a variable to ru script?

Good day!
There is a python + bash script
Using multigrep, I filtered the required list of poppy addresses and figured out how to get a list of IP (bash) based on
them
How to do it in ru3?

import paramiko
import os

host = "192.168.0.1"
port = 22
username = "root"
password = "passwd"

command = "arp -an |grep 'mac1\|mac2\|mac3\|mac4'"

ssh = paramiko.SSHClient()

ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(host, port, username, password)

# using exec_command
#stdin, stdout, stderr = ssh.exec_command("arp -an |grep 'mac1\|mac2\|mac3\|mac4'")
lines = stdout.readlines()
print(lines)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AVKor, 2021-12-13
@shell_guy

$ export test_var='test'
$ echo $test_var
test
$ python3
Python 3.9.2 (default, Feb 28 2021, 17:03:44) 
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.environ['test_var']
'test'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question