#StackBounty: #python #c #python-3.x #ssh #paramiko Is there a method of executing a command then continue the program without command …

Bounty: 100

Hi I am trying to create a function which remotely executes my packet sniffing script on my raspberry pi using paramiko and ssh.

def startPacketReceiver():
    ssh = paramiko.SSHClient()
    ssh.connect(RECV_IP_ADDRESS, username="pi", password="raspberry")
    ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_command("sudo gcc Code/test.c && sudo ./a.out")

The test.c file is the packet sniffing script. It will only terminate with a CTRL-C (or equivalent method). It does not terminate naturally/eventually.

I want to be able to start the receiver and then quit the receiver e.g:


Currently when I run the python script I never get the "Done" print message, meaning that the program is hung on the exec_command and will not continue until it is terminated.

Additional Info

The test.c file loops infinitely, essentially:

    saddr_size = sizeof saddr;
    //Receive a packet
    data_size = recvfrom(sock_raw , buffer , 65536 , 0 , &saddr , (socklen_t*)&saddr_size);
    if(data_size <0 )
        fprintf(stderr,"Failed to get packetn");
        printf("Recvfrom error , failed to get packetsn");
        return 1;
    //Now process the packet
    ProcessPacket(buffer , data_size);

and so to stop it you must CTRL-C it.

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.