Translating with DrWatson… this can take a few seconds the first time.
This is a genuine, complex translation. DrWatson protects commands, error codes, and log output while naturally translating the surrounding text. It’s translated once and saved.
Sergio Peres found that onstat -c shows MSGPATH with an unexpanded $INFORMIXDIR in his bash script. Mike Walker suggested eval or onstat -g cfgMSGPATH, which prints the expanded path. Art Kagel showed a cut-based example. Sergio confirmed Mike's method worked on versions 12 and 14.
Auto-generated by Claude from the posts below — may be imperfect; read the full thread.
Sergio Peres — source: IBM Community (ConnectedCommunity.org) Informix forum
Hi,
I have one script that uses onstat results as arguments, on bash I am veryfing one issue.
As INFORMIXDIR appears on some variables they are not resolved by shell
#!/bin/bash
ONLINELOG=$(onstat -c | grep
"^MSGPATH"
)
# This command return something like $INFORMIXDIR/tmp/online.log
grep
"Something"
"
$ONLINELOG
"
returns
grep: MSGPATH
$INFORMIXDIR
/tmp/online.log: No such file or directory
The variables are defined and loaded into the environment, however $INFORMIXDIR appears as a string
I am using CentOS 8.6 and bash 4.4.20
Thanks for any help
SP
------------------------------
Sergio Peres
AIRC
Coimbra
------------------------------
#Informix
↪ replying to Sergio Peres
Mike Walker — source: IBM Community (ConnectedCommunity.org) Informix forum
You will need to expand INFORMIXDIR to it's value in the script. Take a look at the eval command.
Another things is to use onstat -g cfgMSGPATH and grep the value from that output...that usually has expanded the full path already.
------------------------------
Mike Walker
xDB Systems, Inc
www.xdbsystems.com
------------------------------
↪ replying to Sergio Peres
Art Kagel — source: IBM Community (ConnectedCommunity.org) Informix forum
Sergio:
It's not complaining about INFORMIXDIR, it is complaining about the arguements to bash on the ## line.
Is this what you are trying to accomplish:
art@Elezar-II:~$ cat aa
#!/usr/bin/bash
export ONLINELOG=$(onstat -c | grep "^MSGPATH" | cut -d\\ -f2)
# This script sets an environment variable for the rest of the session from
# ONCONFIG output from onstat
echo "ONLINELOG=$ONLINELOG"
art@Elezar-II:~$ ./aa
ONLINELOG=$INFORMIXDIR/tmp/online.log
------------------------------
Art S. Kagel, President and Principal Consultant
ASK Database Management Corp.
www.askdbmgt.com
------------------------------
↪ replying to Mike Walker
Sergio Peres — source: IBM Community (ConnectedCommunity.org) Informix forum
Thanks for reply,
It work like a charm :)
Best regards
------------------------------
Sergio Peres
AIRC
Coimbra
------------------------------
↪ replying to Art Kagel
Sergio Peres — source: IBM Community (ConnectedCommunity.org) Informix forum
Thanks for reply Art,
My problem is that shell do not replace variable for the correct value an dreturns error.
Using Mike solution works fine and give teh correct value, I have tested over version 12 and 14 and works on both.
Best regards,
SP
------------------------------
Sergio Peres
AIRC
Coimbra
------------------------------
We use strictly necessary cookies to make this site work. With your
consent we’d also use optional cookies for analytics and marketing. You can accept all,
reject all, or choose. Read our Cookie Policy.