Below is a small bash script. The expected output after connecting to the server is to print Hello World
and in the next line the current month and year - like Jan 2014
. For using VARIABLE1
in the 'here document', I need dollar expansion, so the terminating character ~
is not quoted.
VARIABLE1="World"
ssh username@server.domain.com <<~
echo "Hello $VARIABLE1"
COMMAND1=`date +%b`
COMMAND2=$(date +%Y)
echo "$COMMAND1 $COMMAND2"
~
The actual output that I get is this :
Pseudo-terminal will not be allocated because stdin is not a terminal.
Password:
Hello World
When ssh
is run in verbose mode, here is last part of the output:
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Trying private key: *****
debug1: Trying private key: *****
debug1: Next authentication method: keyboard-interactive
Password:
debug1: Authentication succeeded (keyboard-interactive).
debug1: Final hpn_buffer_size = *****
debug1: HPN Disabled: 0, HPN Buffer Size: *****
debug1: channel 0: new [client-session]
debug1: Enabled Dynamic Window Scaling
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
Hello World
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 0 clearing O_NONBLOCK
Transferred: sent 1552, received 2360 bytes, in 0.1 seconds
Bytes per second: sent 17253.2, received 26235.6
debug1: Exit status 0
Could somebody point out the bug here? Why doesn't it print Jan 2014
?