Getting command output and putting into newfile


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Getting command output and putting into newfile
# 8  
Old 12-05-2008
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.
# 9  
Old 12-05-2008
Hello All,

Below code is giving the same output as this:/omp/bin/TICLI "op:alarm,all" > outputfile.can you please explain what 2>&1 is doing.

Code:
/omp/bin/TICLI "op:alarm,all" > outputfile 2>&1


Second Solution:


Code:
OUT=$(/omp/bin/TICLI "op:alarm,all") && echo $OUT > outputfile

Above code is giving this error on execution:

KarachiOMP root> ./code2
./code2: syntax error at line 5: `OUT=$' unexpected


Can you please find whats the issue.

Third there is no issue of resources as i have the admin rights of the box.

My requirement is to just get complete output of the command in the outputfile.
/omp/bin/TICLI "op:alarm,all" > outputfile

but problem is this that everytime differnet amount of data comes into output file, sometimes only few lines and sometime enough but not complete.

Regards,
Waqas Ahmed
# 10  
Old 12-05-2008
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:

Code:
OUT=`/omp/bin/TICLI "op:alarm,all"` && echo $OUT > outputfile

Instead of "$(...)" you use backticks (not single quotes) like `...`
# 11  
Old 12-05-2008
By "resources" I believe phpfreak is referring to physical resources NOT permissions.

You could be limited by memory, cpu, file handles, drive space, etc...
# 12  
Old 12-05-2008
Code:
OUT=`/omp/bin/TICLI "op:alarm,all"` && echo $OUT > outputfile

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.
# 13  
Old 12-05-2008
Quote:
second it is also changing the output format.
That is because you need to quote the "$OUT" variable as follows:

Code:
OUT=`/omp/bin/TICLI "op:alarm,all"` && echo "$OUT" > outputfile

Note:

echoing a variable that has newlines in the variable contents can cause all \n (newline) characters to be stripped out when not quoting.
# 14  
Old 12-05-2008
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Insert title as output of command to appended file if no output from command

I am using UNIX to create a script on our system. I have setup my commands to append their output to an outage file. However, some of the commands return no output and so I would like something to take their place. What I need The following command is placed at the prompt: TICLI... (4 Replies)
Discussion started by: jbrass
4 Replies

2. Shell Programming and Scripting

Need help putting output on one line

Good afternoon, I have been searching the web, and these forums for help. I will try my best to explain the issue, and what my desired results are. I am doing queries in MYSQL, and need the output to be sent to a file. That file needs to have things with the same ID on the same line. To... (14 Replies)
Discussion started by: brianjb
14 Replies

3. UNIX for Dummies Questions & Answers

Putting the Current -date in the Output File

Hi guys, Just want to ask how can I make a script that will perform like this. 1. Execute the command 2. Then the output of the command will be redirected to a file 2. The file that has been created will have a date on it equivalent to the date and time it was created (or maybe after the... (5 Replies)
Discussion started by: rymnd_12345
5 Replies

4. Shell Programming and Scripting

putting color on output file script

do you have any simple script on how to change the color and font of a string in a script example echo "====================================" echo " sample color script" echo "====================================" echo " hello " echo " bye" on hello,... (3 Replies)
Discussion started by: lhareigh890
3 Replies

5. Shell Programming and Scripting

Putting echo output as input to stat

I have a string with escape differentiators as a result of searching for a file using find. Essentially find returned to my shell variable several absolute paths each ending with the file name and each path/file separated by \n. Echo recognizes the escape sequence and is able to print the paths... (3 Replies)
Discussion started by: Ebodee
3 Replies

6. Shell Programming and Scripting

How to redirect the output to multiple files without putting on console

How to redirect the output to multiple files without putting on console I tried tee but it writes to STDOUT , which I do not want. Test.sh ------------------ #!/bin/ksh echo "Hello " tee -a file1 file2 ---------------------------- $>./Test.sh $> Expected output: -------------------... (2 Replies)
Discussion started by: prashant43
2 Replies

7. Shell Programming and Scripting

sed *.csv from file > newfile with /n

I have a an output file with a format: something blah1.csv blah2.csv blah3.csv somethingelse and I'm trying to use sed to pull all the *.csv entries out and put them 1 per line on a new file. I can't quite figure out how to write them to a new file with carriage returns, is there a simple way... (8 Replies)
Discussion started by: unclecameron
8 Replies

8. UNIX for Dummies Questions & Answers

Command display output on console and simultaneously save the command and its output

Hi folks, Please advise which command/command line shall I run; 1) to display the command and its output on console 2) simultaneous to save the command and its output on a file I tried tee command as follows; $ ps aux | grep mysql | tee /path/to/output.txt It displayed the... (7 Replies)
Discussion started by: satimis
7 Replies

9. Shell Programming and Scripting

How to compare 2 file to newfile......

Hi all Member i want compare 2 file to newfile I am new to shell script, just wanted you guy to help. example file A CM-00000BN_Oth-VAS-0000392 CM-00000BNSEED_Oth-Spe-0000392 CM-00000KJ_Pos-Pro-0000806 CM-00000KJ_Pos-Pro-0000810 CM-00000KJ_Pos-Pro-0000812 CM-00000KJ_Pos-Pro-0000814... (1 Reply)
Discussion started by: ooilinlove
1 Replies

10. Shell Programming and Scripting

Putting screen output in a log file

I want to output screen messages to a logfile when executing an automated script. I have tried the script and command to do this but with no luck. Thanks, Nicole (5 Replies)
Discussion started by: nsutti
5 Replies
Login or Register to Ask a Question