Arlina
16th January 2023, 09:43
Hi All,

There is a shell script which accepts inputs in following way:

bin/sh.uabc <username> <Enter>
Enter Input 1 : <input 1> <Enter>
Enter Input 2 : <input 2> <Enter>
Enter Input 3 : <input 3> <Enter>

I want to execute this from Baan program using shell.

Here is the code-snippet I tried:

long sh.ret
string str.command(1000)
string tmp.str(1)
tmp.str = " "
str.command = "/$BSE/sh.uabc " & strip$(form.id)& "echo -ne '\n' "& strip$(tmp.str)&"echo -ne '\n' "& strip$(tmp.str)&"echo -ne '\n' "& & strip$(tmp.str)& "echo -ne '\n'"

sh.ret = shell(str.command,0)

But it returns '127'
Never worked on shell script earlier.
Is the shell calling correct? Where am I going wrong?

günther
16th January 2023, 16:40
Hi.

Sorry, but it cannot work this way for some reasons.

Here is a simple example, that should work:

# shell script; save it as demo1.sh, chmod 777 demo1.sh
USERNAME=$1
echo "USERNAME is [$USERNAME]"

echo "Enter Input 1:"
read INPUT1
echo "INPUT1 is [$INPUT1]"

echo "Enter Input 2:"
read INPUT2
echo "INPUT2 is [$INPUT2]"

echo "Enter Input 3:"
read INPUT3
echo "INPUT3 is [$INPUT3]"
exit 1

Now run this
a)

./demo1.sh user

-> you will be asked for Input 1 to 3 and after Input, you will get the result.

b)

echo "1\n2\n3" | ./dem1.sh user

-> you do not need enter more data; reason: the read command reads data from "standard input", and that is given by the echo command and the pipe mechanism.

Regards
Günther