Search code examples
macosshellubuntuoh-my-zsh

Pseudo-terminal will not allocated because stdin is not a terminal & mess: ttyname failed: Inappropriate ioctl for device


I've written a shell script to scp, ssh, delete a directory, unzip, and remove the zip file

#!/bin/bash

tar -czf zipfile.tar.gz ./* .??*
scp zipfile.tar.gz [email protected]:/var/www/html/wp-content/themes
rm zipfile.tar.gz

ssh [email protected] << 'ENDSSH'
cd /some/directory
rm -rf zipfile
mkdir zipfile
tar xf zipfile.tar.gz -C zipfile
rm zipfile.tar.gz
ENDSSH

I am noticing that the files are successfully transferred and unzipped. The zip file is also successfully removed from the server. However, I notice that I'm receiving these messages in the terminal

zipfile.tar.gz  100% 224KB ...
Pseudo-terminal will not be allocated because stdin is not a terminal.
...
Welcome to Ubuntu 18.04.3 LTS...
...

0 packages can be updated.
0 updates are security updates.

mesg: ttyname failed: Inappropriate ioctl for device

Running the script before the second block (ENDSSH) seems to not output those messages and executes successfully.

Is the ENDSSH causing the issue?


Solution

  • u can write like this:

    ssh -tt [email protected] << ENDSSH
    your code
    exit
    ENDSSH
    

    u try it.