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
  • 84,225
  • 14
  • 89
  • 153
user3341779
  • 29
  • 2
  • 6

0 Answers0