Andy_bat
Andy_bat

Reputation: 11

How to interact with an application on a remote computer via tail?

There is a need to send commands to a remote application via tail. Locally I'm currently using tail, I want to control it remotely, but I can't get it to work.

I tried paramiko libraries, I couldn’t install and try python-sshtail. What other options are there?


Managed to tame a paramiko

import paramiko
hostname = '192.168.1.2'
port = 22
username = 'user'
password = 'pass'

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(hostname, port, username, password)
.......
command = '"Connect:"  > /root/pu/mypipe'
stdin, stdout, stderr = ssh.exec_command(command)
stdin.close()

It was necessary to send the command in pipe (/root/pu/mypipe)

Upvotes: 0

Views: 94

Answers (1)

Jochen Schultz
Jochen Schultz

Reputation: 641

There are multiple options.

ssh username@remote-server-ip 'command-to-run'

this on command line might be the easiest.

You could also use ansible

In python you might want to look into https://github.com/ansible/ansible-runner

But since you wrote "tail" it sounds like you are trying to follow logfiles.

For that there are plenty of options like LOKI/Grafana or logstash or graylog

Upvotes: 0

Related Questions