send carriage return to java application from a shell

Multi tool use
Multi tool use

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












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 "%sn" 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 ?







share|improve this question





















  • 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 at 12:08






  • 1




    Which shell are you using? Which software does print the Match error?
    – andcoz
    Jun 27 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 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 at 14:28











  • pls, can anyone help me?
    – GiaCorsa
    Jun 28 at 13:12














up vote
0
down vote

favorite












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 "%sn" 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 ?







share|improve this question





















  • 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 at 12:08






  • 1




    Which shell are you using? Which software does print the Match error?
    – andcoz
    Jun 27 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 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 at 14:28











  • pls, can anyone help me?
    – GiaCorsa
    Jun 28 at 13:12












up vote
0
down vote

favorite









up vote
0
down vote

favorite











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 "%sn" 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 ?







share|improve this question













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 "%sn" 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 ?









share|improve this question












share|improve this question




share|improve this question








edited Jun 27 at 15:24









Tim

463211




463211









asked Jun 27 at 12:05









GiaCorsa

1




1











  • 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 at 12:08






  • 1




    Which shell are you using? Which software does print the Match error?
    – andcoz
    Jun 27 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 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 at 14:28











  • pls, can anyone help me?
    – GiaCorsa
    Jun 28 at 13:12
















  • 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 at 12:08






  • 1




    Which shell are you using? Which software does print the Match error?
    – andcoz
    Jun 27 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 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 at 14:28











  • pls, can anyone help me?
    – GiaCorsa
    Jun 28 at 13:12















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 at 12:08




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 at 12:08




1




1




Which shell are you using? Which software does print the Match error?
– andcoz
Jun 27 at 12:14




Which shell are you using? Which software does print the Match error?
– andcoz
Jun 27 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 at 13:45





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 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 at 14:28





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 at 14:28













pls, can anyone help me?
– GiaCorsa
Jun 28 at 13:12




pls, can anyone help me?
– GiaCorsa
Jun 28 at 13:12















active

oldest

votes











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f452206%2fsend-carriage-return-to-java-application-from-a-shell%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes










 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f452206%2fsend-carriage-return-to-java-application-from-a-shell%23new-answer', 'question_page');

);

Post as a guest













































































qT kbBAzzLxqMUVoATZj45H1IG,S jOMqXVfDYinD0T3dURFx,VHPx3
K727r V2z41w dz rX4nBc39zZ5rIUQ,rcXuGvnCAOKIX 1pH,MShxcM av5Ed16M,lBhUdFtK,3 jQPdwcBKe,ARnxSwFLKlE4Uph

Popular posts from this blog

How to check contact read email or not when send email to Individual?

How many registers does an x86_64 CPU actually have?

Displaying single band from multi-band raster using QGIS