Sponsored Content
Top Forums Shell Programming and Scripting Variable name change in a loop Post 302436884 by canduc17 on Tuesday 13th of July 2010 11:19:10 AM
Old 07-13-2010
Your example, scottn, works fine.
But my real case is a little bit more complicated...here a portion of it:
Code:
for I in UL_LAT UR_LAT LR_LAT LL_LAT UL_LON UR_LON LR_LON LL_LON ; do
            # Convert every value from 71 4 17.92 in 71.071644443
            DEGREES=$( echo ${I} | awk '{ print $1 }' )
            MINUTES=$( echo ${I} | awk '{ print $2 }' )
            SECOND=$(  echo ${I} | awk '{ print $3 }' )
            eval $I=$( echo "scale=9; ${DEGREES}+${MINUTES}/60+${SECOND}/3600" | bc )
        done

Executing that I obtain:
Code:
(standard_in) 1: illegal character: U
(standard_in) 1: illegal character: L
(standard_in) 1: illegal character: _
(standard_in) 1: illegal character: L
(standard_in) 1: illegal character: T
(standard_in) 1: syntax error
(standard_in) 1: illegal character: U
(standard_in) 1: illegal character: R
(standard_in) 1: illegal character: _
(standard_in) 1: illegal character: L
(standard_in) 1: illegal character: T
(standard_in) 1: syntax error
(standard_in) 1: illegal character: L
(standard_in) 1: illegal character: R
(standard_in) 1: illegal character: _
(standard_in) 1: illegal character: L
(standard_in) 1: illegal character: T
(standard_in) 1: syntax error
(standard_in) 1: illegal character: L
(standard_in) 1: illegal character: L
(standard_in) 1: illegal character: _
(standard_in) 1: illegal character: L
(standard_in) 1: illegal character: T
(standard_in) 1: syntax error
(standard_in) 1: illegal character: U
(standard_in) 1: illegal character: L
(standard_in) 1: illegal character: _
(standard_in) 1: illegal character: L
(standard_in) 1: illegal character: O
(standard_in) 1: illegal character: N
(standard_in) 1: syntax error
(standard_in) 1: illegal character: U
(standard_in) 1: illegal character: R
(standard_in) 1: illegal character: _
(standard_in) 1: illegal character: L
(standard_in) 1: illegal character: O
(standard_in) 1: illegal character: N
(standard_in) 1: syntax error
(standard_in) 1: illegal character: L
(standard_in) 1: illegal character: R
(standard_in) 1: illegal character: _
(standard_in) 1: illegal character: L
(standard_in) 1: illegal character: O
(standard_in) 1: illegal character: N
(standard_in) 1: syntax error
(standard_in) 1: illegal character: L
(standard_in) 1: illegal character: L
(standard_in) 1: illegal character: _
(standard_in) 1: illegal character: L
(standard_in) 1: illegal character: O
(standard_in) 1: illegal character: N
(standard_in) 1: syntax error

Any ideas?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

change if-else loop to while-do

Hello friends, i wrote a script which includes a couple of if-else loops but i have to change it to while-do loop as it is not allowed to use "break" in if-else loop in bash. #!/bin/bash -x NUM=`find . -name ufsdump_output1.txt | xargs egrep "End-of-tape detected"` if ; then echo "OK!"... (6 Replies)
Discussion started by: EAGL€
6 Replies

2. Shell Programming and Scripting

Variable value dosent change after the loop changes it

i am new to shell scripting. this is similar to the code which i was writing for some other work. i want the variable 'x' to have the value which it will finally have at the end of the loop ( the number of directories ). but the value of 'x' only changes inside the loop and it remains '0' out-side... (3 Replies)
Discussion started by: chathura666
3 Replies

3. Shell Programming and Scripting

Change Variable Value from Multiple Scripts and Use these Variable

Hi to All, Please find below details. file_config.config export file1_status="SUCCESS" export file2_status="SUCCESS" file_one.sh I am calling another two shell script from these script. I need to pass individual two script status (If it's "FAILED") to file_main.sh. file_main.sh I... (2 Replies)
Discussion started by: div_Neev
2 Replies

4. Shell Programming and Scripting

[SHELL: /bin/sh] For loop using variable variable names

Simple enough problem I think, I just can't seem to get it right. The below doesn't work as intended, it's just a function defined in a much larger script: CheckValues() { for field in \ Group_ID \ Group_Title \ Rule_ID \ Rule_Severity \ ... (2 Replies)
Discussion started by: Vryali
2 Replies

5. Shell Programming and Scripting

printing variable with variable suffix through loop

I have a group of variables myLINEcnt1 - myLINEcnt10. I'm trying to printout the values using a for loop. I am at the head banging stage since i'm sure it has to be a basic syntax issue that i can't figure out. For myIPgrp in 1 2 3 4 5 6 7 8 9 10; do here i want to output the value of... (4 Replies)
Discussion started by: oly_r
4 Replies

6. Shell Programming and Scripting

Change a field value in a loop

Hi guys, i have an executable file that contains several records and fields. One of the records has a variable filed that must be changed each time i want to execute the file. Would it be possible that i can use a loop to change the value of that field? Suppose that the field address is: Record... (5 Replies)
Discussion started by: saeed.soltani
5 Replies

7. Shell Programming and Scripting

Array Variable being Assigned Values in Loop, But Gone when Loop Completes???

Hello All, Maybe I'm Missing something here but I have NOOO idea what the heck is going on with this....? I have a Variable that contains a PATTERN of what I'm considering "Illegal Characters". So what I'm doing is looping through a string containing some of these "Illegal Characters". Now... (5 Replies)
Discussion started by: mrm5102
5 Replies

8. Shell Programming and Scripting

Doing a loop to change a value in a file

Hi, I have an N number of files in a directory. I like to write a shell script that would make identical plots for each one of these files. The files have names such as: t00001.dat t00002.dat t00003.dat t00004.dat t00005.dat . . . t00040.dat i.e. the... (4 Replies)
Discussion started by: lost.identity
4 Replies

9. Shell Programming and Scripting

[Solved] How to increment and add variable length numbers to a variable in a loop?

Hi All, I have a file which has hundred of records with fixed number of fields. In each record there is set of 8 characters which represent the duration of that activity. I want to sum up the duration present in all the records for a report. The problem is the duration changes per record so I... (5 Replies)
Discussion started by: danish0909
5 Replies

10. UNIX for Dummies Questions & Answers

Change argument in a for loop

In a "for i in *FD.CPY do" loop, I need to change .CPY to .layout so the executed command would be reclay blahFD.CPY >blahFD.layout What do I need to do to modify a copy of i to use after the > symbol? TIA (5 Replies)
Discussion started by: wbport
5 Replies
PERROR(3F)																PERROR(3F)

NAME
perror, gerror, ierrno - get system error messages SYNOPSIS
subroutine perror (string) character*(*) string subroutine gerror (string) character*(*) string character*(*) function gerror() function ierrno() DESCRIPTION
Perror will write a message to fortran logical unit 0 appropriate to the last detected system error. String will be written preceding the standard error message. Gerror returns the system error message in character variable string. Gerror may be called either as a subroutine or as a function. Ierrno will return the error number of the last detected system error. This number is updated only when an error actually occurs. Most routines and I/O statements that might generate such errors return an error code after the call; that value is a more reliable indicator of what caused the error condition. FILES
/usr/lib/libU77.a SEE ALSO
intro(2), perror(3) D. L. Wasley, Introduction to the f77 I/O Library BUGS
String in the call to perror can be no longer than 127 characters. The length of the string returned by gerror is determined by the calling program. NOTES
UNIX system error codes are described in intro(2). The f77 I/O error codes and their meanings are: 100 ``error in format'' 101 ``illegal unit number'' 102 ``formatted i/o not allowed'' 103 ``unformatted i/o not allowed'' 104 ``direct i/o not allowed'' 105 ``sequential i/o not allowed'' 106 ``can't backspace file'' 107 ``off beginning of record'' 108 ``can't stat file'' 109 ``no * after repeat count'' 110 ``off end of record'' 111 ``truncation failed'' 112 ``incomprehensible list input'' 113 ``out of free space'' 114 ``unit not connected'' 115 ``invalid data for integer format term'' 116 ``invalid data for logical format term'' 117 ``'new' file exists'' 118 ``can't find 'old' file'' 119 ``opening too many files or unknown system error'' 120 ``requires seek ability'' 121 ``illegal argument'' 122 ``negative repeat count'' 123 ``illegal operation for unit'' 124 ``invalid data for d, e, f, or g format term'' 4.2 Berkeley Distribution June 7, 1985 PERROR(3F)
All times are GMT -4. The time now is 07:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy