How to create a shell script to read a foldername from a text file and go to the folder?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to create a shell script to read a foldername from a text file and go to the folder?
# 8  
Old 01-28-2013
Linux How to create a shell script to read a foldername from a text file and go to the folder?

when I ran the new code then it went in loop and I was not even able to kill the processes.

Here is the flow I am trying to achieve:

I have an input file testlist.txt in which I have folder names msml1003, msml1004, msml1005 etc
I have folders msml1003, msml1004 etc which reside in a folder msml.
I have msml1003.xml, msml1004.xml inside folders msml1003, msml1004 etc
My code should read the foldername from "testlist.txt" and then go to msml/msml1003/ and copy msml1003.xml in sipp script given below. Once its done then it should write the results in results.csv file for pass or fail as per the response from the server.
After completing 1 test case then it will go to the next and so on and once it is done then it should exit automatically.
I have following code. Please help me to complete the full cycle as mentioned above.
Code:
#checking the file existence
if [ -f testlist.txt ]
then
echo "File testlist.txt Found"

#else
#echo "File does not exist"

    if [ -d msml ]
then
   echo "msml directory exist"
else
echo "Directory does not exist"
fi
fi

# Dleleting the result.csv
if [ -f result.csv ]
then
   rm result.csv
  echo TestID,Remark,Result >> result.csv
fi
#Deleting the old log files

while read i
do
#for i in `cat testlist.txt`

if [ -f msml/$i/$i*logs.log ]
then
    rm msml/$i/msml*.log

fi
done < testlist.txt

#echo >&2

echo "done deleting old logs. Press any key to continue"
read -sn 1

#Executing sipp script

#Executing the test suite

while read i
     do
echo "Test $i is exexuting"

#      if [$i=""]
#then
#     exit 1
#   fi

       if [ -f msml/$i/$i.xml ]
then


#       if [-f $i]
#     then
#echo "Test $i is exexuting"
   sipp $2 -i $1 -m 1 -l 1 -s msml -sf msml/$i/$i.xml --trace_logs -timeout $3 &
else
         echo "msml/$i/$i.xml does not exist"

fi

done < testlist.txt

Moderator's Comments:
Mod Comment First select the code or data segment before using the CODE button (see here )

Last edited by Scrutinizer; 01-28-2013 at 02:30 AM.. Reason: Removed code tags so that it worked
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Create new folder and text file the same time in one line

Is it possible to create new folder and write a new text file in the folder while the current position is outside the new folder? in one line mkdir folder | echo "hello test"> folder/test.txt not work. (1 Reply)
Discussion started by: cmdcmd
1 Replies

2. Shell Programming and Scripting

Shell script UNIX to read text file line by line

i have a text file as belows, it includes 2 columns, 1st is the column name, 2nd is the file_name data_file.txt column_name file_name col1 file1 col2 file2 col3 file1 col4 file1 col5 file2 now, i would like to... (4 Replies)
Discussion started by: tester111
4 Replies

3. UNIX for Beginners Questions & Answers

How to get script to create a new file that lists folder content sorted by size?

I have a script that sorts and processes unsorted files to newly created directories. Its working great, but I am trying to understand the leanest method to get the script to create an additional file within each newly created directory that: Contains a list of all files in the directory... (4 Replies)
Discussion started by: Braveheart
4 Replies

4. UNIX for Dummies Questions & Answers

Shell script to read lines in a text file and filter user data Shell Programming and Scripting

sxsaaas (3 Replies)
Discussion started by: VikrantD
3 Replies

5. Shell Programming and Scripting

Need to build Shell Script to search content of a text file into a folder consist several files

Have to read one file say sourcefile containing several words and having another folder containing several files. Now read the first word of Sourcefile & search it into the folder consisting sevral files, and create another file with result. We hhave to pick the filename of the file in which... (3 Replies)
Discussion started by: mukesh.baranwal
3 Replies

6. Shell Programming and Scripting

Shell script to read a text file line by line & process it...

Hi , I am trying to write an shell, which reads a text file (from a location) having a list of numbers of strictly 5 digits only ex: 33144 Now my script will check : 1) that each entry is only 5 digits & numeric only, no alphabets, & its not empty. 2)then it executes a shell script called... (8 Replies)
Discussion started by: new_to_shell
8 Replies

7. Shell Programming and Scripting

The scope of the shell/perl script is to read the input text file. Validate the expiry date of each

The scope of the shell/perl script is to read the input text file. Validate the expiry date of each certificate and send the mail to the user. The user takes action to add the new certificate to the storage file and user owns the responsibility to update the input text file with the new certificate... (5 Replies)
Discussion started by: casmo
5 Replies

8. Shell Programming and Scripting

How to read the data from the text file in shell script?

I am having one text file and i need to read that data from my shell script. I will expain you the scenario: Script look like: For name type 1: For age type 2: For Salary type3: echo "Enter the input:" read the data if input is 1 then go to the Text file and print the... (2 Replies)
Discussion started by: dineshmurs
2 Replies

9. Shell Programming and Scripting

Shell script to read lines in a text file and filter user data

hi all, I have this file with some user data. example: $cat myfile.txt FName|LName|Gender|Company|Branch|Bday|Salary|Age aaaa|bbbb|male|cccc|dddd|19900814|15000|20| eeee|asdg|male|gggg|ksgu|19911216||| aara|bdbm|male|kkkk|acke|19931018||23| asad|kfjg|male|kkkc|gkgg|19921213|14000|24|... (4 Replies)
Discussion started by: srimal
4 Replies

10. Shell Programming and Scripting

shell script to read data from text file and to load it into a table in TOAD

Hi....can you guys help me out in this script?? Below is a portion text file and it contains these: GEF001 000093625 MKL002510 000001 000000 000000 000000 000000 000000 000001 GEF001 000093625 MKL003604 000001 000000 000000 000000 000000 000000 000001 GEF001 000093625 MKL005675 000001... (1 Reply)
Discussion started by: pallavishetty
1 Replies
Login or Register to Ask a Question