Linux / UNIX Tech Support Forum
This is a discussion on Read arguments from a file and pass them to binary file within the Shell scripting forums, part of the Development/Scripting category; Hello all, I have a pretty simple script to write, but have never done this before and am having problems. ...
|
|||||||
| Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Hello all,
I have a pretty simple script to write, but have never done this before and am having problems. Hope someone will help! I have a text file that looks like this: 0.001 0.002738613 0.997834325 0.002 0.005477226 0.995668666 0.003 0.008215838 0.993503042 0.004 0.010954451 0.991337467 etc Each of these values is a parameter that I have to input into a program and get results, i.e. !/bin/csh AlphaSim -nx 10 -ny 10 -nz 10 -dx 1 -dy 1 -dz 1 -power -ax 2 -ay 2 -az 2 -zsep {0.001} -rmm {0.002738613} -pthr {0.997834325} -iter 1000 -out power_2x2x2_zsep00{it}.txt so i need this to run for every row in my text file i.e. i need to input three variables from my text file, pass them as parameters to my program, and iterate until end of text file. I'm having such problems, can anyone help? Thanks! Last edited by AHJ; 31-10-2007 at 03:41 AM. |
| Sponsored Links | ||
|
|
|
||||
|
I don't have csh, script but you can write something as follows using bash shell:
Code:
#!/bin/bash
INPUT=file.txt
count=0
exec 3<&0
exec 0<$INPUT
while read line
do
input1=$(echo $line | awk '{ print $1}')
input2=$(echo $line | awk '{ print $2}')
input3=$(echo $line | awk '{ print $3}')
AlphaSim -nx 10 -ny 10 -nz 10 -dx 1 -dy 1 -dz 1 -power -ax 2 -ay 2 -az 2 -zsep ${input1} -rmm ${input2} -pthr ${input3} -iter 1000 -out power_2x2x2_zsep00${count}.txt
count=$( expr $count + 1 )
done
exec 0<&3
__________________
Vivek Gite Linux Evangelist |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| /etc/hosts file | ricc | Linux software | 1 | 08-05-2007 07:32 PM |
| How to install .deb file | raj | Getting started tutorials | 0 | 05-05-2007 12:57 AM |
| convert pdf (ppt file) into wordppt file | sureshbup | Linux software | 1 | 07-12-2006 03:51 PM |
| Log File for AWStats ! | honey bee | Linux software | 1 | 30-03-2006 09:18 PM |
| how to do nohup on an sh file | Linux software | 1 | 30-01-2006 03:57 PM | |