Goal:
- login to a remote system, 2) ask for user input, 3) store the first 4 characters of the input string in a file on the remote system.
What I have:
#!/bin/bash
USERNAME=someUser
HOST="host1"
SCRIPT="echo Enter the string; read -n 4 str; echo $str > file.txt"
ssh -l ${USERNAME} ${HOSTNAME} "${SCRIPT}"
Problem:
The file.txt does not contain the string- it is empty! If I echo $str after the read, it seems empty. Am I missing anything?