Thursday, October 28, 2021

[SOLVED] Bash script execution after login success does not trigger

Issue

I can successfully login from local to a remote server using the bash script. When the login is successful, after a one-line execution, the script does not run to execute other lines. what am I to do to make it execute the script to the end?

#! /bin/bash
    sshpass -p 'remotepassword' ssh -o StrictHostKeyChecking=no [email protected]
    ls -l /var/
    sudo mkdir /var/mydirectories

Solution

This work better than my last answer

    sshpass -p 'remotepass' ssh -o StrictHostKeyChecking=no [email protected]  << EOF
        ls -l /tmp/
        mkdir /tmp/mydirectories
        uname -a
        w
EOF


Answered By - Incrivel Monstro Verde