LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-14-2006, 02:53 AM   #1
ruchikasingh
LQ Newbie
 
Registered: Jun 2006
Posts: 1

Rep: Reputation: 0
Urgent


The code in ksh script is using a “read” in a while loop that caused variables defined within the loop to be out of scope after the while loop exited.

pls any can give an idea why variables are refreshed after the loop exits.
 
Old 06-14-2006, 03:11 AM   #2
IBall
Senior Member
 
Registered: Nov 2003
Location: Perth, Western Australia
Distribution: Ubuntu, Debian, Various using VMWare
Posts: 2,088

Rep: Reputation: 62
1) Please don't call your threads "Urgent". It isn't to anyone on this forum, and won't get you help any faster.

2) Most programming languages use the concept of blocks to define scope, and I assume KSH scripting is no different. The body of a loop generally defines a block. Variables defined within a block will not be availalbe outside the block.

If you need to use variables both inside and outside a loop, then simply declare those variables outside the loop.

I hope this helps
--Ian
 
Old 06-14-2006, 03:11 AM   #3
slackie1000
Senior Member
 
Registered: Dec 2003
Location: Brasil
Distribution: Arch
Posts: 1,037

Rep: Reputation: 46
hi there and welcome to lq,
please, do not use urgent in your thread title. your problem is not urgent here.
can you please post the code? your description is not really clear.
regards,
slackie1000
[edit] beated by IBall
 
  


Reply

Tags
loop, read, while



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
boot sector and lilo collapse !!!!! URGENT URGENT URGEN !!!!! frelihm Linux - Software 21 12-02-2009 10:21 AM
Urgent Question Regarding Urgent Questions! Need Help Now! Crashed_Again LQ Suggestions & Feedback 11 10-17-2007 08:07 PM
Urgent..Im Having A Nightmare..Urgent!!!! midgcool Linux - Software 41 11-30-2004 10:19 AM
Urgent Urgent !!!! Mozilla Keeps All Your Deleted Emails !!!! odin123 Linux - Software 2 01-31-2004 02:22 AM
Urgent hitesh_linux Linux - General 5 12-13-2003 01:46 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:44 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
Open Source Consulting | Domain Registration