Read variables from Access table


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Read variables from Access table
# 1  
Old 09-24-2003
Read variables from Access table

Hi!

I've just started learning shell scripting, and have been somewhat 'thrown in at the deep-end and told to swim' so excuse my complete lack of knowledge and ignorance, but here goes...

I've been given a unix script to 'tidy up'. Basically the script consists of the few lines of code being repeated over and over again with the only a few variables being changd. Example code:

/usr/local/bin/scp echo.xxx.com:/opt/netscape/server4/https-w-cai/logs/access-ref*${LOG_DATE}* /logs/w-cai
> /export/home/xxx/ec_copy_tmp 2>&1

The above is being repeated over and over again in the script with the 'w-cai' being the only piece of text changed each time to different text. Is there a way I can store it as a variable in an access table so that each row in the table is called, one after the other, this section of code is updated with a different variable? Sorry if I'm being unclear, any help appreciated.

eg.

next section of code reads:

/usr/local/bin/scp echo.xxx.com:/opt/netscape/server4/https-countrywide/logs/access-ref*${LOG_DATE}* /logs/w-cai
> /export/home/xxx/ec_copy_tmp 2>&1

As you can see, 'w-cai' has been changed to 'countrywide'.


Last edited by Sn33R; 09-24-2003 at 01:04 PM..
# 2  
Old 09-24-2003
Are the values that change predictable? Do you know what to look for? If so, use a loop. I use an array to hold the values and then loop through them.

The value of "i" would be the variable portion of path that is changing. Replace the echo statement below with your scp

using Korn Shell:
#Create an array called VAR and initialize it with 8 values
set -A VAR 1 Foo 2 Bar 3 Cool 4 Loop

# Iterate through the array and print out each iteration
for i in ${VAR[@]}
do
echo $i
done

Last edited by google; 09-24-2003 at 06:47 PM..
# 3  
Old 09-24-2003
Hi,

Just specify al the dirs you need to look at :

myvar="dir1 dir2 dir3 dir4"

Then fit it around your scp string :

for i in $myvar
do

/usr/local/bin/scp echo.xxx.com:/opt/netscape/server4/${i}/logs/access-ref*${LOG_DATE}* /logs/w-cai
.

done

Must be not too hard.


Regs David
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find and replace variables using a csv table

I have a flat file (template) where I want to replace variables based upon a value in another file (csv). The variables in the template are named %VAR_X_z% The values are in the csv file and X is field 0 of each line and y field 1 and up. Example of the csv: Badidas, 13.00, 12.00, 11.00,... (8 Replies)
Discussion started by: biscayne
8 Replies

2. Solaris

samba read write access to owner and no access to other users

Hi All, I want to configure samba share permission so that only directory creator/owner has a read and write permission and other users should not have any read/write access to that folder.Will that be possible and how can this be achieved within samba configuration. Regards, Sahil (1 Reply)
Discussion started by: sahil_shine
1 Replies

3. UNIX for Advanced & Expert Users

Script to make a table from Named Variables.

I need a shell script to make a table from Named Variables Input File(Can have multiple lines): a=1,b=2,d=4,e=5 a=11,b=12,c=13,d=14 Output file: a,b,c,d,e 1,2,,4,5 11,12,13,14, Thanks in advance (7 Replies)
Discussion started by: shariramani
7 Replies

4. HP-UX

how to read routing table

Hi all, Could someone please explain to me how I should read this routing table, # netstat -rn Routing tables Destination Gateway Flags Refs Interface Pmtu 127.0.0.1 127.0.0.1 UH 0 lo0 32808 10.222.47.82 10.222.47.82 UH... (3 Replies)
Discussion started by: rachael
3 Replies

5. Shell Programming and Scripting

Converting html table data into multiple variables.

Hi, Basically what I am trying to do is the following. I have created a shell script to grab timetabling information from a website using curl then I crop out only the data I need which is a table based on the current date. It leaves me with a file that has the table I want plus a small amount... (2 Replies)
Discussion started by: domsmith
2 Replies

6. UNIX for Dummies Questions & Answers

Teradate table read?

i have to read some data from a teradata table and use them in my shell script.. how do i do that.. we can use BTEQ .. but i don know how to pass the field values as variables to the shell.. please help me.... (8 Replies)
Discussion started by: depakjan
8 Replies

7. Shell Programming and Scripting

Show column names when access a table using perl

Hi all, I am using the following code in order to access the data of a table: my $sql = qq{ SELECT * FROM cc_test_cases}; $sth = $dbh->prepare( $sql ); $sth->execute( ); while(@row1 = $sth->fetchrow_array()) { # print "$row1: $row1\n"; print "@row1\n"; #print("THE VALUE... (1 Reply)
Discussion started by: chriss_58
1 Replies

8. UNIX and Linux Applications

How to access Oracle table using sqlplus

Hi, I want to use sqlplus from server1 sqlplus usr1/pass1@dns1 and I want to connect to an Oracle database from a server2. Unfortunately the database was created on the server1 and on server2. So when I use the command just like that...it connects to the database from the server2. ... (2 Replies)
Discussion started by: AngelMady
2 Replies

9. Solaris

Need some lib in c/c++ to read db table at one go

Hi All, I need some sort of library or module which read the db table at one go and keep in process memory.My problem is that I have a call processing module which handles the network call and goes for db lookup for subscriber profile in oracle db for every call.I am using Oracle Standard Edition... (0 Replies)
Discussion started by: unisuraj
0 Replies

10. IP Networking

any system call in unix to access ip routing table

hi is there any system call by which ip routing table can be accessed. (1 Reply)
Discussion started by: vinodkumar
1 Replies
Login or Register to Ask a Question