awk script for automating the other commercial software command lines


 
Thread Tools Search this Thread
Top Forums Programming awk script for automating the other commercial software command lines
# 1  
Old 12-01-2012
awk script for automating the other commercial software command lines

Dear All

I need awk script to automated the other software command lines.

I am having input files like "shape_eon_input_1.oeb.gz" to "shape_eon_input_968.oeb.gz" total of 968 files.

For each files i have to run command line "
Code:
eon -dbase shape_eon_input_1.oeb.gz -besthits 47000 -prefix Eon-1

I have to run individually 968 times for each file.

Is it possible to automate the command using awk script, such that

for 2nd file it takes command as
Code:
eon -dbase shape_eon_input_2.oeb.gz -besthits 47000 -prefix Eon-2

for 3rd file
Code:
eon -dbase shape_eon_input_3.oeb.gz -besthits 47000 -prefix Eon-3

and for 100th file
Code:
eon -dbase shape_eon_input_100.oeb.gz -besthits 47000 -prefix Eon-100


Kindly advice.

Many Thanks
Balaji
# 2  
Old 12-01-2012
It is certainly possible to do this with awk, but it is much easier in shell.
Try:
Code:
#!/bin/ksh
for file in shape_eon_input_[1-9].oeb.gz shape_eon_input_[1-9][[0-9].oeb.gz shape_eon_input_[1-9][0-9][0-9].oeb.gz
do      seq=${file##*_}
        seq=${seq%%.*}
        eon -dbase $file -besthits 47000 -prefix Eon-$seq
done

This will work with up to 999 files named using this scheme. There are other ways to do this using for i in {1-968} and similar extensions, but these aren't available on all systems and are not defined by the standards. The script above should work with any POSIX conforming shell (I use ksh).
# 3  
Old 12-01-2012
Hi Don

Thanks for help.

I save the script as eon-run.sh and tried to run the script as " sh eon-run.sh"

It shows error as "eon command not found in line 5.

However, the command line works if i run the one by one.

Kindly advice.

Many Thanks
Balaji

Quote:
Originally Posted by Don Cragun
It is certainly possible to do this with awk, but it is much easier in shell.
Try:
Code:
#!/bin/ksh
for file in shape_eon_input_[1-9].oeb.gz shape_eon_input_[1-9][[0-9].oeb.gz shape_eon_input_[1-9][0-9][0-9].oeb.gz
do      seq=${file##*_}
        seq=${seq%%.*}
        eon -dbase $file -besthits 47000 -prefix Eon-$seq
done

This will work with up to 999 files named using this scheme. There are other ways to do this using for i in {1-968} and similar extensions, but these aren't available on all systems and are not defined by the standards. The script above should work with any POSIX conforming shell (I use ksh).

Last edited by bala06; 12-01-2012 at 12:58 PM..
# 4  
Old 12-01-2012
Please enter the following command in your shell:
Code:
echo $PATH
type eon

and add the same two lines as the 2nd and 3rd lines of eon-run.sh.

Then rerun eon-run.sh and compare the output of those two commands.

Note that unless you only intend to run this script once, rather than using the command:
Code:
 sh eon-run.sh

to run this script, it is usually easier to do the following:
Code:
chmod +x eon-run.sh
mv eon-run.sh $HOME/bin

and then just execute it using the command:
Code:
eon-run.sh

but, of course, this assumes that $HOME/bin is an existing directory and that $HOME/bin is in $PATH.

Note that if ksh isn't located in /bin on your system, you'll need to edit the 1st line of eon-run.sh to specify an absolute pathname of ksh on your system.
# 5  
Old 12-01-2012
Hi Don

I am trying todo the second step.

I checked for path of ksh, as you mentioned its in the path /bin/ksh.

If /home/Balaji is my curremt working directory, where should I have to add the lines

Code:
chmod +x eon-run.sh
mv eon-run.sh $HOME/bin

Please advice.

Many Thanks
Balaji



Quote:
Originally Posted by Don Cragun
Please enter the following command in your shell:
Code:
echo $PATH
type eon

and add the same two lines as the 2nd and 3rd lines of eon-run.sh.

Then rerun eon-run.sh and compare the output of those two commands.

Note that unless you only intend to run this script once, rather than using the command:
Code:
 sh eon-run.sh

to run this script, it is usually easier to do the following:
Code:
chmod +x eon-run.sh
mv eon-run.sh $HOME/bin

and then just execute it using the command:
Code:
eon-run.sh

but, of course, this assumes that $HOME/bin is an existing directory and that $HOME/bin is in $PATH.

Note that if ksh isn't located in /bin on your system, you'll need to edit the 1st line of eon-run.sh to specify an absolute pathname of ksh on your system.
# 6  
Old 12-01-2012
I repeat: Type those two commands into your shell. And, add them as new lines in eon-run.sh after the line #!/bin/ksh and rerun eon-run.sh.
Compare the results of running those commands in your shell and running those commands in eon-run.sh. (Or just post the output from your shell when you run those commands and post the output from eon-run.sh when you rerun it.)
# 7  
Old 12-01-2012
Hi don

I added the lines

Code:
#!/bin/ksh
echo $/home/Balaji/electrostatics
type eon

for file in shape_eon_input_[1-9].oeb.gz shape_eon_input_[1-9][[0-9].oeb.gz shape_eon_input_[1-9][0-9][0-9].oeb.gz
do      seq=${file##*_}
        seq=${seq%%.*}
        eon -dbase $file -besthits 47500 -prefix Eon-seq
done

and I tried running the command eon_run.sh, it shows error as

Code:
bash: eon_run.sh.: coomand not found

Kindly advice.

Many Thanks
Balaji

Quote:
Originally Posted by Don Cragun
I repeat: Type those two commands into your shell. And, add them as new lines in eon-run.sh after the line #!/bin/ksh and rerun eon-run.sh.
Compare the results of running those commands in your shell and running those commands in eon-run.sh. (Or just post the output from your shell when you run those commands and post the output from eon-run.sh when you rerun it.)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to put the command to remove duplicate lines in my awk script?

I create a CGI in bash/html. My awk script looks like : echo "<table>" for fn in /var/www/cgi-bin/LPAR_MAP/*; do echo "<td>" echo "<PRE>" awk -F',|;' -v test="$test" ' NR==1 { split(FILENAME ,a,""); } $0 ~ test { if(!header++){ ... (12 Replies)
Discussion started by: Tim2424
12 Replies

2. Windows & DOS: Issues & Discussions

Automating an UNIX Based Software Package on Windows

The company I am with is using Oracle Supply Chain Planing 8.12.1 with JDE 8.12. This is a Unix based system running on Windows Servers using Hummingbird Exceed Version 14 for interactive processing We are currently attempting to automate the Advance Planning Agent flows on a couple of... (2 Replies)
Discussion started by: pfaloney
2 Replies

3. Shell Programming and Scripting

awk command to find seq lines

I have a below file FILE.cfg JAN_01 VAR1=4 VAR2=SUM VAR3=PRIVATE JAN_10 VAR1=44 VAR2=GUN VAR3=NATUR JAN_20 VAR1=3 VAR2=TQN VAR3=COMMA code: (JAN_10 is argument passed from script) (6 Replies)
Discussion started by: Roozo
6 Replies

4. Shell Programming and Scripting

Issues with automating SFTP command

Hi All, I am currently looking at automating the steps that I follow to download log files from putty to desktop. I connect to a client's machine through citrix desktop. I am required to download quite a number of application logs to identfiy the issues in production. Steps that is being... (3 Replies)
Discussion started by: krackjack84
3 Replies

5. Shell Programming and Scripting

AWK Command to duplicate lines in a file?

Hi, I have a file with date in it like: UserString1 UserString2 UserString3 UserString4 UserString5 I need two entries for each line so it reads like UserString1 UserString1 UserString2 UserString2 etc. Can someone help me with the awk command please? Thanks (4 Replies)
Discussion started by: Grueben
4 Replies

6. Shell Programming and Scripting

awk command in script gives error while same awk command at prompt runs fine: Why?

Hello all, Here is what my bash script does: sums number columns, saves the tot in new column, outputs if tot >= threshold val: > cat getnon0file.sh #!/bin/bash this="getnon0file.sh" USAGE=$this" InFile="xyz.38" Min="0.05" # awk '{sum=0; for(n=2; n<=NF; n++){sum+=$n};... (4 Replies)
Discussion started by: catalys
4 Replies

7. Shell Programming and Scripting

Automating 'newgrp' command - how?

Hi, I have to add the 'newgrp' command to my login (.cshrc) script. The problem is that if I add it, it comes to infinite look, since newgrp opens new shell again and again. How to automate the newgrp when I have to login, and avoid that loop? Currently I'm thinking of a condition that... (2 Replies)
Discussion started by: moshmosh
2 Replies

8. Shell Programming and Scripting

awk/sed Command : Parse parameter file / send the lines to the ksh export command

Sorry for the duplicate thread this one is similar to the one in https://www.unix.com/shell-programming-scripting/88132-awk-sed-script-read-values-parameter-files.html#post302255121 Since there were no responses on the parent thread since it got resolved partially i thought to open the new... (4 Replies)
Discussion started by: rajan_san
4 Replies

9. Shell Programming and Scripting

Automating Logform Command in a script

Hi all I am trying to create a script to automate the creating of filesystems. The problem I am having is as follows:- After creating the Log Logical Volume, I want to format it, using the logform command. The Logform command expects user intervention, by typing 'y' and 'enter' to continue.... (2 Replies)
Discussion started by: TheDoc
2 Replies

10. Shell Programming and Scripting

How to run awk command having multiple lines

Hi, Can u see the code below. set xyz = `cat testt1.txt | awk '/-----/{\ print $1 }\ ' | tail -1` I need to execute it in c shell . What is wrong with the above command. When i write everything on a single line then it is working. Can anybody help me . (0 Replies)
Discussion started by: nani_g
0 Replies
Login or Register to Ask a Question