Running executables in ksh


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Running executables in ksh
# 1  
Old 04-18-2011
Running executables in ksh

I am trying a set up a very simple korn shell script. It has 2 basic steps.

Firstly I read the first line of a text file (which is a file name)
Secondly I run a fortran executable using that line

I must be doing something wring because it wouldn't work. I know that the executable wants the file name with ' ' around it but I thought I'd done this. Here is my script
Code:
file="filenames"
while read line
do
    ./a.out <<EOF
    ${" ' " $line " ' "},
    EOF
done <"$file

I am obviously misunderstanding something here. I can get the executable run outside the loop if I give it the string, but I need it to run for each line of the file. Do I need to read the file into an array then run it?

Any help would be so great.
Thanks

Last edited by Franklin52; 04-19-2011 at 04:20 AM.. Reason: Please use code tags
# 2  
Old 04-18-2011
I'm not sure what you're trying to do with ${" ' " $line " ' "}, You also forgot an ending quote after "$file

When you run it manually, what exactly do you type?

How about
Code:
while read line
do
        ./a.out <<EOF
${line}
EOF
done <"$file"

# 3  
Old 04-18-2011
The line is a filename so I just type
Code:
./a.out<<EOF
'20090924_001.nc'
EOF

and it runs. The line from the file doesn't have the quotations so I need to pass them to enable to executable to run. I'm not sure how to do that.

Last edited by Franklin52; 04-19-2011 at 04:20 AM.. Reason: Please use code tags
# 4  
Old 04-18-2011
You were trying to be tricky about it, but it's really not Smilie
Code:
while read line
do
        ./a.out <<EOF
'${line}'
EOF
done <"$file"

# 5  
Old 04-18-2011
Thanks. Yeah I assumed it was more difficult than it actually was. I'll try to do things the easy way next time.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Running a KSH file from VPS on Godaddy

i have looked for a week and tried a few things, but nothing seems to work so joined here. I have a go daddy account and also a vps in germany. In my vps, i run a code script (we will call it codegen) when i run ./codegen i get my question of how many codes do i want to make. With my answer... (9 Replies)
Discussion started by: uksatman
9 Replies

2. Shell Programming and Scripting

ksh script to check if certain process is running

I have to kill the process "test" for a maintenance I do but want the script to check when it comes back up. I can get what I want when I run this while loop: while true;do ps -ef | grep test | grep -v grep | sed -e 's/^*//';sleep 60;done but I want the script to do it for me and as soon as... (6 Replies)
Discussion started by: seekryts15
6 Replies

3. UNIX for Advanced & Expert Users

Running scripts without a hashbang - ksh anomaly?

I noticed some strange looking parameters on some processes on one of our servers, and after a little playing around we deduced that ksh seemed to be adding a (somewhat random) extra parameter when calling a script without a hashbang in it. It looks like it's the partial name of the parent... (10 Replies)
Discussion started by: CarloM
10 Replies

4. Shell Programming and Scripting

Running local script remotely with arguments in ksh

When i use ssh command to execute local script on remote server , I am unable to do it. Please let me know how this can be done in ksh req=abc dte=ghd ssh username@hostname "$req $dte" < run_script.sh (2 Replies)
Discussion started by: lalitpct
2 Replies

5. UNIX for Advanced & Expert Users

Running ksh script from command line

Hi. I have a ksh script I want to run, but I'm connecting through a telnet and I don't want to FTP the scripts itself. is there a way of running the script from command line ? like ksh "The script itself..." Thanks, Ramon (4 Replies)
Discussion started by: mellowcandle
4 Replies

6. Solaris

Problems Running KSH on Solaris 10

Hi, I am currently in the process of testing upgrading from Solaris 8 to Solaris 10. one problem i have encountered is when i am running any of my batch scripts. All my scripts start with #! /bin/ksh so that they will excuted in the ksh shell. but the scripts will not run correctly. The... (3 Replies)
Discussion started by: dshakey
3 Replies

7. Shell Programming and Scripting

ksh script not running in another directory on same server

I have a script that runs fine under my home directory. No syntax errors, runs and returns as expected. When I migrate the script to the UAT directories on the same server for User testing, I get a syntax error. I've checked to make sure the .profile I'm using is the same in the UAT... (1 Reply)
Discussion started by: mpflug
1 Replies

8. Shell Programming and Scripting

KSH, FTP running a set number at a time?

At work we have a script that pulls a file from a list of remote sites every 10 min. Currently it only does this ftp one sites at a time and this process takes up to 8 minutes to complete. I want to have this list of 24 sites and be able to run the ftp from up to 2 sites on the list at a time. I... (1 Reply)
Discussion started by: kofs79
1 Replies

9. Windows & DOS: Issues & Discussions

Running KSH script In SFU

I tried to run my ksh scripts in SFU and it always says "not found" as in the example below: $ .file /bin/ksh: .file: not found Did I miss something in the SFU Installation? (2 Replies)
Discussion started by: ilak1008
2 Replies

10. Shell Programming and Scripting

Editing file during running ksh in HP failed

Hi falks, I have the following program: #!/bin/ksh ed -s /home/ias/v9.0.3/j2ee/OC4J_RiGHTv_HPCD2/applications/Xbip/Xbip/WEB -INF/config/application.properties <<EOF >/dev/null 1 d . d . a application.filePath.core = /core-HPCD2/Html/ application.filePath.xbip =... (2 Replies)
Discussion started by: nir_s
2 Replies
Login or Register to Ask a Question