only the weirdest thing happened with me just now. I was debugging a shell script and I found that a step that was supposed to execute later was getting executed prior to another step for no reason. You know any ?
i mean have a look at the following command-
here it tries to grep first(and hence gives an ambiguous output) and later displays the xstatus.(It should do the opposite,right?)
also any idea what the command which frsh does ? it gives no output on my system. But it sure does something.
Your valuable inputs are always welcome
~cheers
Last edited by vbe; 05-27-2013 at 10:18 AM..
Reason: Please use code tags dor your code and data, thanks
First of all I don't understand this syntax:
Can you explain what you are trying to do? I think this statement is wrong and I really doubt if it works!
Yes, the "DISPLAY" command should execute and pipe it's output to grep. It would help if you could post the whole script, or at least the portions that include the assignment to the DISPLAY variable. It might also help to post the output.
Not knowing exactly what command has been assigned to DISPLAY, I can only guess, and my first thought is that the command's normal output is to standard error and not standard out. This situation could exhibit the behaviour you describe as grep might appear to execute first (failing because of an immediate end of file on standard input?) and the standard error from the command still appearing on the tty device.
Again, that is only a guess, and posting more of the script will certainly help people answer your question.
again please consider something like this "cat abc.txt | grep 123"
All I wanna know is if there's any way that script greps first and cats later ?
We can take my script later on because its a little confidential. I cannot disclose it. Not even a snippet. But thats the crux of it !
hope ya'll understand
We understand that the command:
prints any line in the file abc.txt that contains the string "123". We understand that the command:
does exactly the same thing much more efficiently.
You're saying that the command:
is running whatever $GREP expands to before it runs the command [if. This will probably give a syntax error because you most likely do not have a utility named [if. Since you won't tell us what error was displayed, you haven't told us what system you're using, you haven't told us what shell you're using, and you won't even use CODE tags; you're asking us to work with our hands tied behind our backs. I can guess that you would probably have better luck with:
but there is no way that we can guess whether or not that might do what you want done with the information you have provided.
This User Gave Thanks to Don Cragun For This Post:
Hi,
Is there any debugging tool for Unix Shell Script like we have gdb in C/C++?
Also please let me know how to close the thread is it automatic or we have to close it manually.
Thanks and Regards (1 Reply)
Newbie question. I cannot get "set -n" or "set -noexec on" to work on Linux or AIX! According to the man page and what I read online, it should inform me of syntax errors without executing commands in your script.
So, can someone PLEASE explain why this does not work?
... (2 Replies)
I have been following a tutorial on bash which has proven to be very helpful. However, i am stuck with a command not found issue when asking for a y/n response from the user. Below is the part of code I believe is giving me grief... I have been trying to work through this for 3 hours now.... Please... (5 Replies)
Hello, Some one asked me in the inteview.... The question is,
How do we debug the schell script before even running..... Interviewer
told me one clue... There is SET command to accomplish this... Can any
one tell me what kind of set commands.... Thanks. (2 Replies)
is there any way you can add a breakpoint in a script so you can stop on it?
i have used -xv in my shebang but the script just runs and i want it to stop at a specific point in the script.
appreciate any help. (1 Reply)
Hi All,
How to debug the unix shell script? which one is the best way to do the debuging ?
suggession would be appreciate
Regards,
Siva P
Bangalore (2 Replies)
Hi all,
Am working on a script to understand the flow control of it..
Since i am from a C background i looking out for an easy way to analyze the script as it runs ..
In C/C++ we have F7 that starts execution from main() and proceeds accordingly..
I was wondering if there is a same approach... (2 Replies)
Hello all,
I am trying to run a script and have not had much success running it...ne help debugging it will be appreciated..The ftp script alone works but not within the while loop.
below is the script
#!/usr/bin/ksh
destination_server=servename
destination_user_id=un... (1 Reply)
Hi,
I was using AIX - ksh shell , and inorder to debug shell script I used set -vx to echo all the commands which are being executed.
Can anybody tell me the corresponding method in HP-UX - in tcsh shell.
Regards
Shihab (1 Reply)