Sponsored Content
Top Forums Shell Programming and Scripting Code checking for all values in the same if statement. Post 46752 by oracle8 on Friday 23rd of January 2004 05:44:17 PM
Old 01-23-2004
Code checking for all values in the same if statement.

I am trying to set up a variable based on the name of the file.

Code:
function script_name {

if [ $1='pms.upload.log' ]
then
job_name='MONITOR'
return job_name;

elsif [ $1='pms.download.log'
then
job_name='REJECT'
return job_name

elif [ $1='pms.pre.mon.log' ]
then
job_name='VERSION'
return job_name

fi
}
for i in `ls *log`
do
script_name $i
done.

For some reason the conditon in 1st if condition is being evaluated to true all the times.

Any help is appreciated.
Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

checking valid values in variable

I'm using the following in my script. if echo $cpuidle |/usr/bin/egrep ; then when I issue this statement it issues the value of the variable back to stdout which ends up in my output file. Is there a better way to write this? I'm using ksh on solaris 9. (3 Replies)
Discussion started by: MizzGail
3 Replies

2. Shell Programming and Scripting

Error code checking

I'm trying to create a directory from my Perl script. Only if the there was an error I want to let the user know about it. So if the folder exists is ok. This is what I think should work: `mkdir log 2>/dev/null`; if($? == 0 || $? == errorCodeForFileExists) { everyting is fine } else {... (3 Replies)
Discussion started by: jepombar
3 Replies

3. UNIX for Dummies Questions & Answers

checking parameter values passed to script

Hi, I will pass 3 parameters for a script.I have to check the file name and create a new file name with time stamp. the parameters which i'm passing are /dir/stg/filename.txt /dir/path/head.txt /dir/path/tail.txt Now i have to check filename like : if it is a.txt i have to create... (2 Replies)
Discussion started by: ammu
2 Replies

4. Shell Programming and Scripting

checking the return code

hi i have a file, i am reading line by line and checking a line contains a string , `grep "Change state" $LINE` if then echo "The line contains---" else echo "The line does not contains---" i need to check the return code , but i am getting an error ... (4 Replies)
Discussion started by: Satyak
4 Replies

5. Shell Programming and Scripting

Iterative statement to cut values from a line

Hi I am new to shell scripting and trying to get values from a text file, I have a text file with values seperated with "|". like aga|120220090525|120220090525|120220090525|120220090530 bab|120220090530|120220090530|120220090535|120220090535|120220090535... (4 Replies)
Discussion started by: mannepalli
4 Replies

6. Shell Programming and Scripting

SH if statement using FLOAT values

Today I spent longer than I'd like to admit figuring out how to write a Bourne shell IF statement that tests a FLOAT value before executing a block of statements. Here's the solution I found, which invokes bc. Hope this will come in handy for someone: value = testval = if then body... (5 Replies)
Discussion started by: sjepsen
5 Replies

7. Shell Programming and Scripting

Checking the Column values in a file.

Hi All, I have a file that has ~2.9Millions lines with 32 columns respectively. The columns numbers 23,27 are the primary Keys for the file. The fields are delimited by TAB. I need to check the condition If Column number: 20 is NOT NULL Column number: 21 is not 0 Column number: 22 is... (7 Replies)
Discussion started by: filter
7 Replies

8. Shell Programming and Scripting

code checking

i was just wondering how would you check , beside the lock method, if an instance of another code is already running and if it is then output a message to the user saying the program is already running and exit!! the code is in BOURNE SHELLL!!! thanks in advance!! (3 Replies)
Discussion started by: bshell_1214
3 Replies

9. Shell Programming and Scripting

Checking for duplicate code

I have a short line of code that checks very rudimentary for duplicate code: sort myfile.cpp | uniq -c | grep -v "^.*1 " | grep -v "}" It sorts the file, counts occurrences of each line, removes single occurrences and removes the ubiquitous closing brace. The language is C++, but is easily... (3 Replies)
Discussion started by: figaro
3 Replies

10. Shell Programming and Scripting

Pass values to case statement in a function korn shell

I'm in the process of writng a function that consists of a case statement is there a way of calling the function and passing a value to it? ie function1 () { case opt1 do ..... opt2 do..... esac } function opt1 I'm aware the syntax is not correct, but you get the general idea. (1 Reply)
Discussion started by: squrcles
1 Replies
QUEUE_SPLITTER(1)														 QUEUE_SPLITTER(1)

NAME
queue_splitter - PgQ consumer that transports events from one queue into several target queues SYNOPSIS
queue_splitter.py [switches] config.ini DESCRIPTION
queue_spliter is PgQ consumer that transports events from source queue into several target queues. ev_extra1 field in each event shows into which target queue it must go. (pgq.logutriga() puts there the table name.) One use case is to move events from OLTP database to batch processing server. By using queue spliter it is possible to move all kinds of events for batch processing with one consumer thus keeping OLTP database less crowded. QUICK-START Basic queue_splitter setup and usage can be summarized by the following steps: 1. pgq must be installed both in source and target databases. See pgqadm man page for details. Target database must also have pgq_ext schema installed. 2. edit a queue_splitter configuration file, say queue_splitter_sourcedb_sourceq_targetdb.ini 3. create source and target queues $ pgqadm.py ticker.ini create <queue> 4. launch queue splitter in daemon mode $ queue_splitter.py queue_splitter_sourcedb_sourceq_targetdb.ini -d 5. start producing and consuming events CONFIG
Common configuration parameters job_name Name for particulat job the script does. Script will log under this name to logdb/logserver. The name is also used as default for PgQ consumer name. It should be unique. pidfile Location for pid file. If not given, script is disallowed to daemonize. logfile Location for log file. loop_delay If continuisly running process, how long to sleep after each work loop, in seconds. Default: 1. connection_lifetime Close and reconnect older database connections. log_count Number of log files to keep. Default: 3 log_size Max size for one log file. File is rotated if max size is reached. Default: 10485760 (10M) use_skylog If set, search for [./skylog.ini, ~/.skylog.ini, /etc/skylog.ini]. If found then the file is used as config file for Pythons logging module. It allows setting up fully customizable logging setup. Common PgQ consumer parameters pgq_queue_name Queue name to attach to. No default. pgq_consumer_id Consumers ID to use when registering. Default: %(job_name)s queue_splitter parameters src_db Source database. dst_db Target database. Example config file [queue_splitter] job_name = queue_spliter_sourcedb_sourceq_targetdb src_db = dbname=sourcedb dst_db = dbname=targetdb pgq_queue_name = sourceq logfile = ~/log/%(job_name)s.log pidfile = ~/pid/%(job_name)s.pid COMMAND LINE SWITCHES
Following switches are common to all skytools.DBScript-based Python programs. -h, --help show help message and exit -q, --quiet make program silent -v, --verbose make program more verbose -d, --daemon make program go background Following switches are used to control already running process. The pidfile is read from config then signal is sent to process id specified there. -r, --reload reload config (send SIGHUP) -s, --stop stop program safely (send SIGINT) -k, --kill kill program immidiately (send SIGTERM) USECASE
How to to process events created in secondary database with several queues but have only one queue in primary database. This also shows how to insert events into queues with regular SQL easily. CREATE SCHEMA queue; CREATE TABLE queue.event1 ( -- this should correspond to event internal structure -- here you can put checks that correct data is put into queue id int4, name text, -- not needed, but good to have: primary key (id) ); -- put data into queue in urlencoded format, skip actual insert CREATE TRIGGER redirect_queue1_trg BEFORE INSERT ON queue.event1 FOR EACH ROW EXECUTE PROCEDURE pgq.logutriga('singlequeue', 'SKIP'); -- repeat the above for event2 -- now the data can be inserted: INSERT INTO queue.event1 (id, name) VALUES (1, 'user'); If the queue_splitter is put on "singlequeue", it spreads the event on target to queues named "queue.event1", "queue.event2", etc. This keeps PgQ load on primary database minimal both CPU-wise and maintenance-wise. 03/13/2012 QUEUE_SPLITTER(1)
All times are GMT -4. The time now is 10:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy