If that piece of code is in a script; try to rrun the commands interactively. I found some differences in the behaviour of egrep (up to a total freeze !) while running interactively or in a script.
Hi,
I have Solaris 8 Sun Blade Ultra 150 system. And, I tried your command in the Unix Window. Its still showing "Variable Syntax". Thanks for your support though. Please help how do I get over this error.
Basically, I get huge data as a return value. In that data this "Status" is present. hence, I want to grep on this status and update the user accordingly.
2) What exactly do you mean by 'huge data as a return value'? Do you have a terminal output that you can post, either for the problem we're wading through here...or the original 'huge data' that you're trying to resolve...?
I'm to hedge and say you've only resolved an immediate concern...you might not have resolved your real concern. You never responded on the 'huge data' question, so I'm guessing you might still see the issue in another spot. In fact, your sample if..then statement appears to be a mock-up instead of a real-life condition. What is it you're trying to accomplish? Are you trying to capture SQL return codes or something...?
You're only going to see a variable work if you've piped something into it; $? is the same concept, but on the shell's level instead of the process. Whatever allows you to redirect into tempfile.txt should also allow you to simply pipe this same result into your egrep statement, and thereby get $return to match your goal.
Hi,
It is a network response over TCP/IP channel. So, if the transfer of data fails, I get some response. In that response, there are Status codes. So, to check for success, I need to grep on that status code and then show an error dialog to the user.
So, piping variables was not working. Hence, I decided to dump the response in a file and then do the egrep. That worked !