0

Goal:

  1. 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?

Cyrus
  • 77,979
  • 13
  • 71
  • 125
user3341779
  • 19
  • 1
  • 6

0 Answers0