Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 968
  • Last Modified:

While loop break

We have a shell script that reads extdata.txt and extracts the information and merges the data into a table. There two while loops in the program. The inner loop is iterating too many times.
The requirement is we need to extract data only for 12 threads but it is running more number of time and extracting same data. Need to help to restrict the number of iterations.

Thanks
heartbeat-timestamp.sh
extdata.txt
0
basirana
Asked:
basirana
4 Solutions
 
tel2Commented:
Hi basirana,

I don't have time to study your script in detail, but...

Q1. What kind of shell script is this?  bash?

Q2. Have you tried running it in debug mode, like this:
    bash -x heartbeat-timestamp.sh
to try to see what's going on?
Or you could add some more echo statements at key points to show you what's happening.

BTW, no need to have "exit 0" at the very end of a shell script, as that happens by default.
0
 
arnoldCommented:
Is it perl (last), or a different shell Bash,Korn (break)
http://www.cyberciti.biz/faq/bash-while-loop/
0
 
basiranaAuthor Commented:
It is working now. It is a append problem
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
basiranaAuthor Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for basirana's comment #a38366644

for the following reason:

thanks
0
 
tel2Commented:
Hi basirana,

Could you show us exactly what the problem was, please?
And how did you discover it?

Thanks.
0
 
simon3270Commented:
The "exit 0" at the end is quite useful if you want to be sure that the script returns success - otherwise it will return the output status of the last command it ran, which may be non-zero even though the script was successful.

The odd one is the "exit 0" just before the "done" of the "while  (true)" loop - that basically means that the loop only ever executes once.  That would only make sense if there was a "continue" or "break" within the loop which altered the flow.

Also you don't need the parentheses wound the "true" - "while true" would work just fine.
0
 
tel2Commented:
@simon3270,
Thanks for your correction to my "exit 0" comment.  Didn't realise that.  Good to know.

@basirana,
When deleting a question, instruction #2 that appears on the webpage is:
'Did you find your own solution? If you did, please click "Cancel", post your solution, and then close the question by clicking "Accept as Solution" on your own post.'
I don't think "It is working now. It is a append problem" gives enough detail for anyone to see what you have done to fix this.

I know I've basically asked this before, but I haven't yet seen a reply from you, so:
1. Could you show us exactly how you fixed the problem, please?  (I suggest you provide the new code, or at least the changes.)
2. And how did you discover the cause of the problem?

Thanks.
0
 
basiranaAuthor Commented:
thanks
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now