Help with scripting how to read a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with scripting how to read a file
# 1  
Old 03-28-2012
Help with scripting how to read a file

Hi,
I do lot of things with license, we have so many different application which requires different license for each. I need to find out how to pass the file name from a directory on to script?
This is what I did so for, please help on the XYZ below.

Code:
 
#!/bin/bash
#
# If lmgrd is already executing, don't re-execute it.
#
FLEXHOME=/usr/flexlm
LMGRD=$FLEXHOME/lmgrd
LICFILE=$FLEXHOME/lic/{XYZ}
 
## XYZ - some server have three file, some of them have 10 files here.  
#I need to find out how to do ls take the name of the file to pass it here. 
 
LOGFILE=/tmp/logs/{XYZ}.log
case $1 in
'start')
        if [ -x $LMGRD ]
        then
        if [ -f $LICFILE ]
        then
        $LMGRD -c $LICFILE -l $LOGFILE
        fi
        fi
        ;;
'stop')
        if [ -x $LMGRD ]
        then
        $LMGRD -x lmdown
        fi
        ;;
*)
        echo "usage: /etc/init.d/lmgrdsh {start|stop}"

# 2  
Old 03-28-2012
Just cycle through the instances

Code:
#!/bin/bash
#
# If lmgrd is already executing, don't re-execute it.
#
FLEXHOME=/usr/flexlm
LMGRD=$FLEXHOME/lmgrd
for LICFILE in  $FLEXHOME/lic/* ;do
        INSTANCE=$(basename $LICFILE)
        LOGFILE=/tmp/logs/${INSTANCE}.log
        case $1 in
        'start')
               if [ -x $LMGRD ]; then
                     if [ -f $LICFILE ];then
                          $LMGRD -c $LICFILE -l $LOGFILE
                     fi
               fi
        ;;
        'stop')
              if [ -x $LMGRD ];then
                   $LMGRD -x lmdown
             fi
        ;;
        *)
           echo "usage: /etc/init.d/lmgrdsh {start|stop}"
    esac
done


Last edited by Skrynesaver; 03-28-2012 at 04:55 PM.. Reason: repaired substitution
This User Gave Thanks to Skrynesaver For This Post:
# 3  
Old 03-28-2012
Thank you so much. You make it so simple, I was pulling my hair and I was going in the wrong way to figure that out.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to read multiple files at same time through UNIX scripting?

How to read multiple files at simultaneously? (1 Reply)
Discussion started by: Priyanka_M
1 Replies

2. Shell Programming and Scripting

Read csv file, convert the data and make one text file in UNIX shell scripting

I have input data looks like this which is a part of a csv file 7,1265,76548,"0102:04" 8,1266,76545,"0112:04" I need to make the output data should look like this and the output data will be part of text file: 7|1265000 |7654899 |A| 8|12660000 |76545999 |B| The logic behind the... (6 Replies)
Discussion started by: RJG
6 Replies

3. 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

4. Shell Programming and Scripting

Request for file read option in Unix shell scripting

Hi Friends, I would like to read all the record from one txt file to other file txt For example I have two txt file a.txt and b.txt. I need to read a.txt record by record and I need add the system date @ end of each record before moving it to b.txt. Could you please share the coding for... (4 Replies)
Discussion started by: vinoth124
4 Replies

5. Shell Programming and Scripting

[Solved] Read a line from one string till to another.... Unix scripting..

So i have a file which contains paths to JPG images separated by a space. I have to separate them each path to another file. So, I have to search all strings that start from /home/ and ends with .jpg or .png Then write each one to another file... Can you please help me on doing this???:cool: (11 Replies)
Discussion started by: hakermania
11 Replies

6. Shell Programming and Scripting

how read the flat files from shell scripting

We are using sybase data base and we have the data base name called MasterDB. The data baase MasterDB contains 100's of tables like sample1, sample2, sample3...etc...sample100 To take the count of every table we have to execute the following commands use MasterDB //DB name go //execute... (1 Reply)
Discussion started by: shijoe
1 Replies

7. UNIX for Advanced & Expert Users

how read the flat files from shell scripting

We are using sybase data base and we have the data base name called MasterDB. The data baase MasterDB contains 100's of tables like sample1, sample2, sample3...etc...sample100 To take the count of every table we have to execute the following commands use MasterDB //DB name go //execute... (1 Reply)
Discussion started by: shijoe
1 Replies

8. Shell Programming and Scripting

Read/write file with scripting

Is there any way to write to a text file with scripting? I need to write to a text file two lines of text for the amount of files in the current directory. (9 Replies)
Discussion started by: Fred Goldman
9 Replies

9. UNIX for Advanced & Expert Users

How to Read config (.cfg) files using shell scripting

Hello Friends I am new to this forum and this is my first post. I have to write a script in which i have to read data from a configuration ( .cfg) file. And also i have to execute/call some already written scripts from this script. Can you people plpease help me on this regards. Thanks... (5 Replies)
Discussion started by: smallwonder
5 Replies

10. Shell Programming and Scripting

why shell scripting takes more time to read a file

i have done a coding in shell scripting which reads a file line by line and does something....it takes more than 30 seconds to execute for a single file. when i do the same with perl scripting it takes less than a second. is that shell scripting is not efficient while working with large number of... (1 Reply)
Discussion started by: brkavi_in
1 Replies
Login or Register to Ask a Question