LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris
User Name
Password
Solaris / OpenSolaris This forum is for the discussion of Solaris, OpenSolaris, OpenIndiana, and illumos.
General Sun, SunOS and Sparc related questions also go here. Any Solaris fork or distribution is welcome.

Notices


Reply
  Search this Thread
Old 08-27-2007, 09:11 AM   #1
anhtt
LQ Newbie
 
Registered: Jul 2007
Posts: 27

Rep: Reputation: 15
Export data to file


"op:alarm,all" is a tool of us.
If we run this command, it will export data results.
And we save data results to a file by a command as following:
"op:alarm,all" > /tmp/ac1
But sometimes it's not enough results is saved to file "/tmp/ac1". And script will continue to run the another command. ( We're put "op:alarm,all" into a script ).
Thefore, the script won't operate exactly. Are there another way to save data results to /tmp/ac1 ?
 
Old 08-27-2007, 09:41 AM   #2
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Tribblix, Ubuntu/WSL
Posts: 9,773

Rep: Reputation: 469Reputation: 469Reputation: 469Reputation: 469Reputation: 469
Can you tell more about this command ?
 
Old 08-27-2007, 03:23 PM   #3
Blinker_Fluid
Member
 
Registered: Jul 2003
Location: Clinging to my guns and religion.
Posts: 683

Rep: Reputation: 63
I agree with jiligre we need more information.

Taking a wild guess at the description I would say it sounds like your first command isn't finished creating your file when the second one starts. (sound correct?)

If so you may need to add a sleep command between them to give the first one time to complete. There are probably other things you can do that may be more creative but with the lack of info it's hard to say what they are.
 
Old 08-28-2007, 09:23 AM   #4
choogendyk
Senior Member
 
Registered: Aug 2007
Location: Massachusetts, USA
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,197

Rep: Reputation: 105Reputation: 105
Also, at the end of your "op:alarm,all" > /tmp/ac1, you should make sure you have a semicolon:

"op:alarm,all" > /tmp/ac1;

that will ensure that it completes that command before going on the the next in the script. Sleep would be something you would try if the op:allarm,all thing automatically spawned itself into background and you needed to wait for it. There are also some more sophisticated scripting tricks in that situation where you could capture the pid and wait for the process to complete. However, I think the semicolon is the likely thing to try, since that is a common problem/solution and simple.
 
Old 08-28-2007, 11:25 AM   #5
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Tribblix, Ubuntu/WSL
Posts: 9,773

Rep: Reputation: 469Reputation: 469Reputation: 469Reputation: 469Reputation: 469
Hmmm, this semicolon trick looks like black magic to me.

Do you have any material demonstrating its reality ?
 
Old 08-28-2007, 05:43 PM   #6
choogendyk
Senior Member
 
Registered: Aug 2007
Location: Massachusetts, USA
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,197

Rep: Reputation: 105Reputation: 105
I've fixed scripts that way in the past.

I don't have my reference materials with me here, and I haven't been able to come up with a google search that turns it up. So I'll investigate it tomorrow at work and post what I find.
 
Old 08-28-2007, 11:29 PM   #7
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Tribblix, Ubuntu/WSL
Posts: 9,773

Rep: Reputation: 469Reputation: 469Reputation: 469Reputation: 469Reputation: 469
To anhtt:

Please don't confuse the "Report" button which should only be used to report a problematic post to the moderators with the "Post Reply" or "Quote" ones which are used to add a post to the thread.

So far you have wrongly reported choogendyk with this comment:
Quote:
Sorry,all
Maybe the "op:alarm,all" tool is not stable.
and myself with that one:
Quote:
The "op:alarm,all" is a tool. It will give us all alarm of system.
Our system is used to monitor the alarm of the transceiver base station ( it's also called BTS ) in a mobile communication system.
We have a lot of BTSs. So the command will export a lot of data.
I want to ask you "Are there another command to save data to file ?"
 
Old 08-29-2007, 10:32 AM   #8
choogendyk
Senior Member
 
Registered: Aug 2007
Location: Massachusetts, USA
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,197

Rep: Reputation: 105Reputation: 105
Ok, we're kind of off on a tangent now, but this is a reply to jlliagre regarding the semicolon in shell scripts. Originally, I suggested that adding a semicolon could resolve issues with timing in anhtt's script.

So, I've done my research now, and it's not 100% clear. A reading of the man pages posted here:

http://www.cs.princeton.edu/~jlk/kor...doc/man93.html

gets a little tangled in semantics - a pipeline is "one or more commands" (note "one"), the "semicolon causes the sequential execution of the preceding pipeline", and the "ampersand causes the asynchronous execution of the preceding pipeline". So, it would seem that the semicolon has the function I described.

However, the man pages here:

http://www.mkssoftware.com/docs/man1/sh.1.asp

covering "sh, resh, ksh, bash POSIX-compliant (Korn/Bourne-Again) shell and command interpreter" refers to the unescaped newline as equivalent to the ; sequential execution operator. That would imply that if you have a command followed by a newline followed by another command, that the first command will be completed before the second is begun.

So, I may have to revisit some of the scripts that I worked on in the past and see if I can better determine what's up with them. I wouldn't say this closes the case, but it does call into question the "lore" that had been passed down to me. There very well could be variances in implementations; and, in optimized multi-processing environments, there are a lot of other things going on. Using sleep would be equally questionable if one simply bought that either semicolon or newline guaranteed the completion of the preceding command. But I have used both semicolons and sleep in my /etc/init.d/apache script, because the restarting of apache by logadm was periodically resulting in a failure to start again when the shutdown had not yet completed. Granted, there I'm dealing with a multi-threaded application with ssl ports open and calling yet another control script, apachectl, to actually issue the kill, so, yeah, complications. And sometimes it does almost seem like black magic, even when we think we grok the system.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Export data from Evolution to Openoffice mcle Linux - Software 2 08-21-2011 06:26 PM
gnuplot, pull X data from file, specify Y data at cmd line? hedpe Programming 5 03-15-2007 11:32 PM
how to export kontact data dh2k Linux - Software 0 06-28-2006 12:24 PM
export data to excel or oenoffice.org using Qt pragnya Linux - General 1 01-20-2006 04:55 AM
PHP: export data to openoffice calc lucesei Programming 3 12-11-2005 12:28 AM

LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris

All times are GMT -5. The time now is 03:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration