The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
undefined symbol: clock_gettime' error dpa078 High Level Programming 4 04-09-2008 09:29 AM
undefined error amitrajvarma Shell Programming and Scripting 1 01-11-2008 07:32 AM
Prompting for Input - Getting Undefined Variable Kartheg UNIX for Dummies Questions & Answers 1 06-27-2007 05:24 PM
Undefined reference to Error svh High Level Programming 2 02-11-2006 12:23 AM
ld: 0711-317 ERROR: Undefined symbol: .hello stockdan High Level Programming 2 11-25-2003 05:43 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-19-2008
c00kie88 c00kie88 is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 63
undefined variable error

Hi all,

i have a script.

When i run the script, on the prompt i use: $> . ./blah; i have an undefined variable error.

But when i run the script using $> ./blah ; it works fine.

I know it was something to do with FORK() process.

But i have a simple script , using while loop.

#!/bin/sh

answer=0

while [ "$answer" -gt 10 ];

do

echo "Hello"

done

It's complaining my "answer" variable.

How to fix the problem? Do i need to use PATH?

Please help
  #2 (permalink)  
Old 05-19-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
What is the difference between when it works and when it doesn't? To me they both look the same.

Your script, as copy+pasted from above, runs fine, although it never actually enters the loop, because $answer is 0. I get no complaints; and indeed, sh doesn't care whether you have explicitly defined a variable or not, and will not produce a complaint like the one you are reporting. Is it perhaps somehow being run by something else than /bin/sh?
  #3 (permalink)  
Old 05-19-2008
divh18 divh18 is offline
Registered User
  
 

Join Date: May 2008
Posts: 7
Unquote $answer...

Quote:
Originally Posted by c00kie88 View Post
while [ "$answer" -gt 10 ];
  #4 (permalink)  
Old 05-19-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Quote:
Originally Posted by divh18 View Post
Unquote $answer...
I'm sorry, but that's completely a red herring.
  #5 (permalink)  
Old 05-20-2008
c00kie88 c00kie88 is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 63
Does actually matter to run . ./blah or ./blah
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 10:39 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0