LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-31-2004, 06:35 PM   #1
illiniguy3043
Member
 
Registered: May 2004
Location: Illinois
Distribution: Ubuntu 8.04
Posts: 56

Rep: Reputation: 15
Problems with a script (bash shell, Red Hat 7.2)


Hi I'm currently writing a script in the bash shell (I did
echo $SHELL to make sure)and can't get it to work. First, let
me explain what I want it to do: I have a ton of files of the
format cyl1.flo_00002_9.87069E-02, where 9.87069E-02 is the
time in the simulation that this flow solution was written. I
want to take a bunch of files like this and feed them into a
postprocessor program with the following format:
<progname> cyl1 <stamp> 2, where <stamp> is just
9.87069E-02 and <progname> is just the name of the
postprocessor program The postprocessor puts out a cyl1.plt
file and another file that I don't care about for each moment
in time so I'll have about 100 .plt files when I'm done; the
problem is that every time I run <progname> it overwrites
the .plt file and I need a .plt file for each moment in time
that I have .flo files for so I want to convert the cyl1.plt
file directly after it's written at each moment in time to
cyl1_n.plt where n is the iteration number. I want the
numbering scheme to start at the first data point in time and
go in order from there (i.e. the .plt file from the
postprocessor where cyl1.flo_00001_0.00000E-00 was the input
should be changed to cyl1_1.plt from cyl1.plt and so on.) I
ran into a problem in that when I do ls in my directory where
all the .flo files that it lists the .flo files in order of
the first number of the timestamp, i.e. 2.333E-03 is ahead of
2.567E-01 and so on so I wrote my script to do all the 10E-04
terms, then 10E-03, etc. etc. When I run the script with
source rename I get the error bash: ELF: command not found.
I attached my script to this email so you could have a look at
it and maybe help me out a little. Any help you can give me
would be greatly appreciated; the guys I work for are
out of town this week so I don't really have anyone to help me
out and I'm still relatively new to Linux outside of simple operations like moving files, deleting files, running programs, etc. I pasted in my script code below in order to try to make things easier.

Thanks



#Declare k, the last digit of the lowest exponent and store that value in k

declare -i k
echo "Please enter last digit of lowest exponent"
read k

#Declare n, the number of the iteration where the first solution in time is #given n=1 and then numbered in order

let n=1
for k in 4 3 2 1 0
do
for file in ~/dir1/dir2/dir3/dir4/cyl1.flo_?????_?.?????E-0$k
do

#read in each .flo file passing only its time stamp on the end as a #parameter

<progname> cyl1 $(file:15:11) 2

#increase n by 1 in order to make the files the correct number

n=n+1
cp cyl1.plt cyl1_$n.plt
done

done
 
Old 05-31-2004, 06:50 PM   #2
Looking_Lost
Senior Member
 
Registered: Apr 2003
Location: Eire
Distribution: Slackware 12.0, OpenSuse 10.3
Posts: 1,120

Rep: Reputation: 45
Is this where you're saying the problem is?
n=n+1

should be

let n=n+1 or let n+=1
 
Old 05-31-2004, 07:01 PM   #3
illiniguy3043
Member
 
Registered: May 2004
Location: Illinois
Distribution: Ubuntu 8.04
Posts: 56

Original Poster
Rep: Reputation: 15
I tried doing that and I still get bash: ELF: command not found
 
Old 05-31-2004, 07:20 PM   #4
Looking_Lost
Senior Member
 
Registered: Apr 2003
Location: Eire
Distribution: Slackware 12.0, OpenSuse 10.3
Posts: 1,120

Rep: Reputation: 45
I can't reproduce the ELF error, however the brackets,

$(file:15:11)
to
${file:15:11}


?
 
Old 05-31-2004, 07:32 PM   #5
illiniguy3043
Member
 
Registered: May 2004
Location: Illinois
Distribution: Ubuntu 8.04
Posts: 56

Original Poster
Rep: Reputation: 15
I changed that and I'm still getting the same error. I emailed my system administrator but it's Memorial Day here in the States so no one is working. I think I may need to add something to my PATH because I did a search on everything2.com and it says that the usual reason for the error is something not being in your path. I attempted adding various things in my PATH (I made sure to NOT delete anything out of my PATH) but nothing has worked yet. You have any other possible ideas?
 
Old 05-31-2004, 07:45 PM   #6
Looking_Lost
Senior Member
 
Registered: Apr 2003
Location: Eire
Distribution: Slackware 12.0, OpenSuse 10.3
Posts: 1,120

Rep: Reputation: 45
Fiddled about a little more, I think it's because of the name you have given the script - their is probably a /usr/bin/rename on your system, 'cos source is searching your path it's getting itself messed up when you do source rename

changed the name of the script from rename to something unique bugsbunny or something and see what happens

Hopefully that's it but you never know
 
Old 05-31-2004, 09:32 PM   #7
illiniguy3043
Member
 
Registered: May 2004
Location: Illinois
Distribution: Ubuntu 8.04
Posts: 56

Original Poster
Rep: Reputation: 15
Cool

It works now; I gave it an arbitrary name and is outputting just as I intended. Thanks a lot for your help; now I won't have to make up a bunch of bs next week when the guys I work for at my research job wonder why the hell I didn't get anything done in the week and a half they were gone!!!
 
Old 06-01-2004, 02:49 AM   #8
Looking_Lost
Senior Member
 
Registered: Apr 2003
Location: Eire
Distribution: Slackware 12.0, OpenSuse 10.3
Posts: 1,120

Rep: Reputation: 45
No, problem, I've been assuming there's a reason that you have to use the source command otherwise you could just run it as normal


./rename


or whatever...anyway.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Bash shell script moodupani Linux - General 2 09-01-2005 07:14 AM
Is there bash shell on red hat? paschim Linux - Software 7 08-30-2004 08:07 PM
making .tif files into animated .gif files (bash shell, Red Hat 7.2) illiniguy3043 Linux - Newbie 1 06-01-2004 05:04 PM
converting .tif images to an animated .gif file (Red Hat 7.2, bash shell) illiniguy3043 Linux - General 0 06-01-2004 02:07 PM
BASH shell script help ewarmour Programming 8 05-24-2002 08:57 AM


All times are GMT -5. The time now is 04:21 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration