1

How do I collect user input and store in variables to use in parameters for jar file execution?

Tried using read -p and bash's select command from following link but get errors: How do I prompt for Yes/No/Cancel input in a Linux shell script? here is what I have so far:

#!/bin/bash

echo "Hello "$USER"."
echo "Enter System :"
read name
echo "Enter Format (JPG/PDF):"
read format 

java -jar ~/folder/myjar.jar -input ~/scripts/file -output$format ~/output/$name.$format

This partially works in that it produces output file but the name variable is lost, format variable is generated in string ok. Running this also generates the following errors: ": command not found" under hello user, " ': not a valid identifierame" after entering system name

4

1 回答 1

0

看起来你可能有回车/windows 行终止,尝试运行

dos2unix input.txt

或者

sed 's/^M$//' input.txt > output.txt

或者

tr -d '\r' < input.txt > output.txt
于 2014-08-03T04:34:51.730 回答