0

I have a script that invoke a java/scala application, this application asks the user several inputs.

I want to automatically give the answers to the java app, so I'm creating this script. I have some trouble when it needs to give carriage return to the java application in some default cases.

Now, in this environment OS SunOS 5.10, bash, java, if I run this statement from command prompt it works fine:

printf "%s\n" 1 1 3333333  $'\r' N 80909090 800302 PSC000C0 33 16 COMPANY Y Y $'\r' $'\r' $'\r' $'\r' quit | simula.sh

But if I put the same statement within a shell script, it doesn't work

Match error. The value not match with: [A-Z,a-z,0-9,\s]{1,25}
Match error. The value not match with: [A-Z0-9]{3}(:[^:]+)*

I presume because of regular expressions.

The same behavior if I enter from keyboard within a command prompt CTRL+V CTRL+M to simulate CR instead of $'\r' and it works but doesn't when I put it within a script shell.

Any suggestion ?

  • Welcome to Unix Stackexchange! You can take the tour first and the learn How to Ask a good question. That makes it easier for us to help you. – andcoz Jun 27 '18 at 12:08
  • 1
    Which shell are you using? Which software does print the Match error? – andcoz Jun 27 '18 at 12:14
  • This question gives you a general clue on sending input from a shell script to an interactive program. In the question fdisk utility is used, but the principle seems to be the same. – Tim Jun 27 '18 at 13:45
  • I'm using bash shell (/usr/bin/bash) on SunOS 5.10 Generic_Virtual sun4v sparc sun4v macchine, my script should be call another script calling java application: #!/bin/bash ROOT=/xx/xx/xx CP=$ROOT/scripts/lib/simula.jar:$ROOT/lib/ojdbc6.jar:$ROOT/scripts/lib/scala-library.jar:$ROOT/scripts/lib/xmlmessages.jar:$ROOT/lib/sp-util.jar:$ROOT/lib/protomatter-1.1.9.jar /opt/spr/root/java/bin/java -cp $CP xxxxx -conn jdbc:oracle:thin:@//lxxxxxxxxxxxxx $, java version "1.6.0_22", java appl prints Match error – GiaCorsa Jun 27 '18 at 14:28
  • pls, can anyone help me? – GiaCorsa Jun 28 '18 at 13:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.