Sponsored Content
Top Forums Shell Programming and Scripting while loop error. (command not found) Post 302626791 by Corona688 on Thursday 19th of April 2012 08:08:42 PM
Old 04-19-2012
That's a useless use of eval, and eval is dangerous -- someone could feed text like `rm -Rf ~/` into the program, and it would do it.

Just do this instead:

Code:
i=1
while read var$i
do
        let i++
done <inputfile


Last edited by Corona688; 04-19-2012 at 10:42 PM.. Reason: added input file
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

find command in while loop - how to get control when no files found?

I have the following statement in script: find ${LANDING_FILE_DIR}${BTIME_FILENAME_PATTERN2} -print | while read file; do ... done When there are no files located by the find comand it returns: "find: bad status-- /home/rnitcher/test/....." to the command line How do I get control in... (3 Replies)
Discussion started by: mavsman
3 Replies

2. Red Hat

Command Not Found Error?

Hi, I am beginer to Linux. I have installed Redhat Linux AS 4.0 on my System.Later I created a User Oracle10g for Installing Oracle.Then I logged onto Oracle10g user and crated a Bash Profile and when I run that profile there was an error in that Profile. from then If I type any of Linux Command... (2 Replies)
Discussion started by: praswer
2 Replies

3. Shell Programming and Scripting

file not found error during loop

Hi, I have a strange problem and I'm sure its because I'm doing something stupid. When I loop through all of the files in a directory they cannot be found. Any help would be greatly appreciated. Thanks, -E $ touch a.txt $ touch b.txt $ ls a.txt b.txt $ for f in `ls` ; do... (3 Replies)
Discussion started by: earls
3 Replies

4. UNIX for Dummies Questions & Answers

Loop on array variable returning error: 0 not found

I'm guessing i have a syntax error. I'm not sure it get's past the the while condition. I get an error 0 not found. Simple loop not sure what I'm doing wrong. #!/usr/bin/ksh set -A MtPtArray /u03 /u06 tUbound=${#MtPtArray } echo $tUbound i=0 while ($i -lt $tUbound) do print... (4 Replies)
Discussion started by: KME
4 Replies

5. Shell Programming and Scripting

Command not found error!

Hello everyone, I am using Linux and tcsh shell. I am trying to run a free open source program( which is in the form of a binary file), but every time I run it it gives me an error saying: newhtsg_v1.0:Command not found. I have set permission also for the same. What else can I do to make... (4 Replies)
Discussion started by: ad23
4 Replies

6. UNIX for Dummies Questions & Answers

Command not found error

I have a program called abc installed in /usr/local/bin. My path is as follows: # echo $PATH /sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/root/bin However, when entering the abc command, the following error appears: # abc abc: Command not found When... (7 Replies)
Discussion started by: figaro
7 Replies

7. Linux

command not found error

I installed in VM the Mandriva Linux. But when I fire the make command it gives me command not found error. Seems make is not installed. I also checked in Mandriva control center and no development package is seen there. Will pls let me know how to proceed and get make and other development... (2 Replies)
Discussion started by: rupeshkp728
2 Replies

8. UNIX for Dummies Questions & Answers

Command not found error

$ cat nu who | wc -l $ ls -l nu -rwxr-x--- 1 _ _ 11 Jul 30 12:37 nu //the nu is displayed in green color $ nu bash: nu: command not found I am using a book from 1986 on Unix System V, Release 3, and the Unix system I am connecting to is from my college. Below is the notes from the book:... (4 Replies)
Discussion started by: chip
4 Replies

9. Shell Programming and Scripting

Command not found error 'then'

Could you let me know if my path is having bourne bash echo $PATH /u01/app/oracle/product/10.2.0/db_1/bin:/usr/sbin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/oracle/bin $ which bash /bin/bash $ which ls alias ls='ls --color=tty' /bin/ls Below is... (3 Replies)
Discussion started by: csguna6
3 Replies

10. Shell Programming and Scripting

Variable not found error in while loop

I am unable to use the value of a variable. while ] do LstFldDataPart =`head -n "$LstFldDataPartCntr" "${FeedFileDir}/${FeedFileBadRecs}" | tail -1 | tr -d '\n'` echo $LstFldDataPart JndLstFldDataPart="${JndLstFldDataPart}${LstFldDataPart}" LstFldDataPartCntr=... (3 Replies)
Discussion started by: TomG
3 Replies
Perl::Critic::Policy::ErrorHandling::RequireCheckingRetuUserlContributed PPerl::Critic::Policy::ErrorHandling::RequireCheckingReturnValueOfEval(3)

NAME
Perl::Critic::Policy::ErrorHandling::RequireCheckingReturnValueOfEval - You can't depend upon the value of "$@"/"$EVAL_ERROR" to tell whether an "eval" failed. AFFILIATION
This Policy is part of the core Perl::Critic distribution. DESCRIPTION
A common idiom in perl for dealing with possible errors is to use "eval" followed by a check of $@/$EVAL_ERROR: eval { ... }; if ($EVAL_ERROR) { ... } There's a problem with this: the value of $EVAL_ERROR can change between the end of the "eval" and the "if" statement. The issue is object destructors: package Foo; ... sub DESTROY { ... eval { ... }; ... } package main; eval { my $foo = Foo->new(); ... }; if ($EVAL_ERROR) { ... } Assuming there are no other references to $foo created, when the "eval" block in "main" is exited, "Foo::DESTROY()" will be invoked, regardless of whether the "eval" finished normally or not. If the "eval" in "main" fails, but the "eval" in "Foo::DESTROY()" succeeds, then $EVAL_ERROR will be empty by the time that the "if" is executed. Additional issues arise if you depend upon the exact contents of $EVAL_ERROR and both "eval"s fail, because the messages from both will be concatenated. Even if there isn't an "eval" directly in the "DESTROY()" method code, it may invoke code that does use "eval" or otherwise affects $EVAL_ERROR. The solution is to ensure that, upon normal exit, an "eval" returns a true value and to test that value: # Constructors are no problem. my $object = eval { Class->new() }; # To cover the possiblity that an operation may correctly return a # false value, end the block with "1": if ( eval { something(); 1 } ) { ... } eval { ... 1; } or do { # Error handling here }; Unfortunately, you can't use the "defined" function to test the result; "eval" returns an empty string on failure. Various modules have been written to take some of the pain out of properly localizing and checking $@/$EVAL_ERROR. For example: use Try::Tiny; try { ... } catch { # Error handling here; # The exception is in $_/$ARG, not $@/$EVAL_ERROR. }; # Note semicolon. "But we don't use DESTROY() anywhere in our code!" you say. That may be the case, but do any of the third-party modules you use have them? What about any you may use in the future or updated versions of the ones you already use? CONFIGURATION
This Policy is not configurable except for the standard options. SEE ALSO
See thread on perl5-porters starting here: <http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2008-06/msg00537.html>. For a nice, easy, non-magical way of properly handling exceptions, see Try::Tiny. AUTHOR
Elliot Shank "<perl@galumph.com>" COPYRIGHT
Copyright (c) 2008-2011 Elliot Shank. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license can be found in the LICENSE file included with this module. perl v5.16.3 2014-0Perl::Critic::Policy::ErrorHandling::RequireCheckingReturnValueOfEval(3)
All times are GMT -4. The time now is 10:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy