for getting command output and then putting the output into newfile but the problem is this, that not the complete output goes into newfile and the script stops.
for example: if this commands gives this output
cell 1
cell 2
cell 3
cell 4
No, the below code is still not working correctly, the output file do not contain the complete output of the command.
Actually this command takes time to generate ouput, so is there someway that the script do not ends until the complete output of the command is redirected to the output file.
Hi! There maybe a way but we will find out until you post the code of that certain command.. otherwise we will not see what is really going with your script/command.
agreed, I suspect that some of that output may be stderr and not regular stdout. The "2>&1" will catch ALL output (stderr & stdout) and send to the output file.
I have a feeling this may have something to do with the amount of data you are attempting to write into the file. If so, it's possible that the resources just aren't there on the box. If you're on a shared vhost the admins could be killing the process off before it completes writing as it may alert as a runaway process. So on that note, I hope your on a managed or doing from your own box at home.
If it is a large amount of data, better to save yourself from having to open that file. My suggestion would be to redirect stderr to an empty file. Then look for broken pipes or another from there.
OK "$(command)" is a command expansion technique to get the output of a command into a variable, if your shell does not like that format then you could use:
I used the above code and it is also not giving the complete output, second it is also changing the output format.
i also want to share one more thing. That we have one log folder in which our logs files are maintained on daily basis. Every command we run on TICLI shell that command's output also goes into that logs files.
So whenever i run my script so it do not gives complete output, but in log file complete output of the command comes.
Any idea how that happens, but why its not happening through my script.
Actually "op:alarm,all" takes time for giving complete output. Those commands which output is not very large are working properly with my script but because "op:alarm,all" command takes time for output, the complete output is not coming through script.
Is "/omp/bin/TICLI" a compiled application? Does it call a compiled application? What you may be running into is that the code inside the compiled application is told to output MORE info to a log than what it does on the command line. If that is the case you may be unable to change this without editing the source code to that application and re-compiling.
Now i am using the above code to run the command (op:alarm,all) on TICLI shell, and then trying to grep the output of command through the log file and then putting it into output file.
But now my question is that how i will stop the script when the output of the command will finish. I mean how i can make the script intelligent enough to stop giving output in the output file. And there is one more problem that because i am using grep on LOG file so it will also grep many other unwanted things.