LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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


Reply
  Search this Thread
Old 09-12-2007, 09:30 AM   #1
nagrcm
LQ Newbie
 
Registered: Sep 2007
Posts: 1

Rep: Reputation: 0
Smile Parameters


Hi,

i have small scenario was working on towards an intelligent solution.

I have a shell script which need the following parameters


Load_type: True - Direct
False - Conventional
IP_File : URL of the file
OP_Table : Target table

The parameter file would be like this

False (emp.dat, emp1.dat, emp2.dat) EMP

I want pass these values intelligently from the parameter file

if first field False then
Load_TYPE = False
IP_File = emp1.dat
Op_TABLE = EMP and execute the Shell script
wait for 60 sec and change the value of the IP_FILE to
IP_file = emp2.dat

If First field of parameter file is True then
Load_type=True
IP_FILE = emp.dat
op_table = EMP


Can any one try doing this..using awk or Shell scripting...

I would appreciate any ideas on this.

Thanks
Nag
 
Old 09-14-2007, 11:19 AM   #2
/bin/bash
Senior Member
 
Registered: Jul 2003
Location: Indiana
Distribution: Mandrake Slackware-current QNX4.25
Posts: 1,802

Rep: Reputation: 47
Code:
#!/bin/bash
# Parameters = False EMP emp.dat emp1.dat emp2.dat

PARM_FILE=parm.conf

while read Load_TYPE Op_TABLE IP_FILES
  do
  if [ "$Load_TYPE" = "False" ];then
    IP_FILE=$(echo ${IP_FILES}|cut -d' ' -f2)
    echo "Load = $Load_TYPE: Op = $Op_TABLE: IP File = $IP_FILE"
    echo "Executing the script..."
    sleep 5 
    IP_FILE=$(echo ${IP_FILES}|cut -d' ' -f3)
    echo "Load = $Load_TYPE: Op = $Op_TABLE: IP File = $IP_FILE"
  else
    IP_FILE=$(echo ${IP_FILES}|cut -d' ' -f1)
    echo "Load = $Load_TYPE: Op = $Op_TABLE: IP File = $IP_FILE"
  fi
done <$PARM_FILE
$ cat parm.conf
True EMP emp.dat emp1.dat emp2.dat
./doit
Load = True: Op = EMP: IP File = emp.dat

$ cat parm.conf
False EMP emp.dat emp1.dat emp2.dat
./doit
Load = False: Op = EMP: IP File = emp1.dat
Executing the script...
Load = False: Op = EMP: IP File = emp2.dat


HTH
 
  


Reply



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
streamer parameters Ian D Linux - Software 0 03-18-2007 09:28 AM
many parameters... os2 Programming 3 07-30-2005 04:56 PM
Grub parameters....??? avols143 Linux - General 3 03-19-2004 10:12 AM
using ld parameters artur Programming 4 02-13-2004 02:27 PM
Help with positional parameters Read_Icculus Linux - General 7 11-02-2003 04:23 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:00 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration