LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Closed Thread
 
Search this Thread
Old 11-06-2010, 02:20 PM   #1
kswapnadevi
LQ Newbie
 
Registered: Oct 2010
Posts: 16

Rep: Reputation: 0
shell scripting for accepting input from different directories automatically


The two shell scripts (t1prog and t2prog) are given below they are working fine. The input for the first program is 't1.det' and for second program is 't1.rnaml'. These two input files are in 'dir1' folder. I am executing the shell like 'sh t1prog > t1out' and 'sh t2prog > t2out' from this directory only. Then I am executing a java program 'java RNA'; for this, t1out and t2out are input files used in the program and I am getting the final output on screen.

The input files 't1.det' and 't1.rnaml' are in different folders with same name and with different values. Each folder specifies one gene sequence input files.

In mfold directory there are 5 directors and each directory contains these input files as shown below
cd mfold
dir1 dir2 dir3 dir4 dir5
cd dir1
t1.det t1.rnaml
-----
cd dir5
t1.det t1.rnaml

I requesting you to please help me in shell script to automate this process like t1prog and t2prog first take the inputs from dir1 folder, run the shell and redirect the output to t1out and t2out and after executing the java program with statment 'java RNA' the output will be redirected to a file like 'RNAout1'. Then takes the inputs from dir2 folder, same process again, and redirect the output to 'RNAout2'. Like this for all inputs values from 5 folders. Modify the two shell scripts given below, to accept the inputs in that way.

shell 1: t1prog

1. #!/bin/bash
2. PrintVal() { C=${C#*(}; C=${C%)*}; echo $C | sed 's/).*( /-/'; }
3. while IFS=':=' read A B C
4. do
5. case $(echo $A) in
6. Initial*)
7. ((NotFirst)) && { echo; echo; } || NotFirst=1
8. echo ${B#* }; echo
9. Hairpins=0
10. ;;
11.
12. Hairpin*)
13. ((Hairpins==0)) && echo "$A:"
14. PrintVal
15. ((Hairpins++))
16. ;;
17. Multi-loop)
18. echo "$A:"
19. PrintVal
20. ;;
21. esac
22. done <t1.det

shell 2: t2prog

#!/bin/sh
i=1
while read line
do
freecount=`echo "${line}" | grep -i "free" | wc -l`
poscount=`echo "${line}" | grep -i "position" | wc -l`
if [ $freecount -eq 1 ]
then
rangeoutput=0
else
rangeoutput=1
fi
if [ $rangeoutput -eq 0 ]
then
value=`echo "${line}" | sed -n 's/<.*>\(.*\)<.*>/\1/p'`
echo $value
else
if [ $poscount -eq 1 ]
then
pvalue[$i]=`echo "${line}" | sed -n 's/<.*>\(.*\)<.*>/\1/p'`
if [ $i -eq 2 ]
then
echo "${pvalue[1]} - ${pvalue[2]}"
i=0
fi
i=`expr $i + 1`
fi
fi
done <t1.rnaml
-----------------------------
for one input in dir1 i am executing like this

sh t1prog > t1out
sh t2prog > t2out
java RNA

for inputs in different directories and executing these and redirecting the final ouput after executing 'java RNA' statement to a file is needed.
PLS. KINDLY HELP ME WHICH IS VERY ESSENTAIL FOR ME. THANKING YOU

Last edited by kswapnadevi; 11-07-2010 at 12:14 AM. Reason: replaced the old content with modified one
 
Old 11-06-2010, 02:39 PM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,541
Blog Entries: 28

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Duplicate post reported. Earlier post is http://www.linuxquestions.org/questi...orires-842660/
 
Old 11-10-2010, 12:11 PM   #3
crabboy
Moderator
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,823

Rep: Reputation: 120Reputation: 120
Please follow the discussion in the original thread.
 
  


Closed Thread

Tags
scripting


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
shell scripting for extracting input from different directorires kswapnadevi Linux - Newbie 7 11-09-2010 06:10 AM
Bash Scripting handling user input sections automatically Gavin Harper Programming 3 06-18-2010 10:35 PM
bourne shell scripting ..input .. 91change Programming 2 07-29-2008 07:39 AM
How to automatically date the input directories satimis Programming 5 11-05-2004 09:11 PM
Shell scripting, getting directories atlep Programming 2 09-30-2004 11:21 AM


All times are GMT -5. The time now is 01:36 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration