0

I have a batch file

#content of batch file
@echo off
plink.exe -ssh user@IP.address -m C:\Users\My\Documents\command_test.txt -i C:\Users\My\Desktop\PUTTYKEY.ppk

which connects to a remote ubuntu host using plink.exe and runs the following command to set off the script

#content of command_test.txt
/home/user/script.sh

The script requires user input to select files from a second remote host using zenity file selection and an OpenSSH connection

#code snippet from script.sh
ssh -X Remote_vm_user@Remote2.IP.address <<EOF
zenity --title "please select location of data" --file-selection --directory > directory_selected.tmp
echo "========================="
echo "user selected"
cat directory_selected.tmp
echo "========================="
exit
EOF

This works when executing the script directly when connected using PuTTy

However, when executed using the batch file it returns the error;

Pseudo-terminal will not be allocated because stdin is not a terminal.

I have tried using a variety of options to force it as suggested How to deal with "Pseudo-terminal will not be allocated because stdin is not a terminal."

-t and -tt and -T and -t -t These don't work, no errors are displayed, it just eventually times out

very new to stack overflow so apologies if poor question, suggest edits and I'll amend immediately

  • Just randomly trying something does not mean it will work. the `-tt` option is available on specific *nix shells. What does your help provide? i.e `ssh --help` or `ssh -?` – Gerhard Nov 02 '20 at 15:11
  • @Gerhard `ssh --help usage: ssh [-b bind_address] [-c cipher_spec] [-D [bind_address:]port] [-E log_file] [-e escape_char] [-F configfile] [-I pkcs11] [-i identity_file] [-J [user@]host[:port]] [-L address] [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port] [-Q query_option] [-R address] [-S ctl_path] [-W host:port] [-w local_tun[:remote_tun]] [user@]hostname [command]` – TheMouldinator Nov 02 '20 at 15:15
  • Where is your EOF marker in the commands to be executed remotely? – Raman Sailopal Nov 02 '20 at 15:17
  • @RamanSailopal I dont understand, please could you elaborate? – TheMouldinator Nov 02 '20 at 15:19
  • So you are using `OpenSSH`? – Gerhard Nov 02 '20 at 15:21
  • @Gerhard Will add more details to the question, 1 min – TheMouldinator Nov 02 '20 at 15:25
  • @Gerhard yes, using OpenSSH, had to go check that haha – TheMouldinator Nov 02 '20 at 15:32
  • Run `plink --help`? Do you see the `-t -T enable / disable pty allocation` paramter? – Gerhard Nov 02 '20 at 15:32
  • yes I see the that =) – TheMouldinator Nov 02 '20 at 15:34
  • So try `plink.exe -t -ssh user@IP.address -m C:\Users\My\Documents\command_test.txt -i C:\Users\My\Desktop\PUTTYKEY.ppk` where `-T` will disable pseudo pty. I am guessing here because I do not have plink running. – Gerhard Nov 02 '20 at 15:36
  • Unfortunately everything executes the same as before, same error, with the exception of some weird characters `[3J[H[2J` appearing – TheMouldinator Nov 02 '20 at 15:42
  • You have specified EOF as part of a heredoc but then don't seem to have used EOF at the end of the list of commands? – Raman Sailopal Nov 02 '20 at 15:44
  • ok, I see now that you are issuing ssh using plink and then executing another script to do the ssh.. but Raman has a point, you do not have EOF as the last command in the list. – Gerhard Nov 02 '20 at 15:49
  • my apologies, I have actually got EOF in there, it just didnt copy paste over - EDIT have added `EOF` to end of commands – TheMouldinator Nov 02 '20 at 15:56
  • edit- have added in headers to code snippets to make their origins more clear – TheMouldinator Nov 02 '20 at 15:59

0 Answers0