shell script query


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting shell script query
# 1  
shell script query

hi all

i have a shell script for connecting in sybase env what i need is i have around 10 servers , i need to connect to all servers and retrive the database inforamtion in the servers and display them

any one of u have it request to share it asap !

"QUERY TO Connect to all servers and collect DATABASE information"

---------- Post updated at 08:31 PM ---------- Previous update was at 08:11 PM ----------

hi all below is the script ,just i need a query in this to add ,if any one can please help me in this regard


Code:
#!/bin/sh

#SERVER_TYPE=$1     # rep or sql

SYBASE_VER=`ls -1 $SYBASE | grep ASE- | cut -d"/" -f1`
SYBOCS_VER=`ls -1 $SYBASE | grep OCS- | cut -d"/" -f1`
SYB_OCS=$SYBASE/$SYBOCS_VER
SYB_ASE=$SYBASE/$SYBASE_VER

SYBASE_ASE=$SYBASE_VER; export SYBASE_ASE
SYBASE_OCS=$SYBOCS_VER; export SYBASE_OCS
ISQL_CMD=$SYBASE/$SYBASE_OCS/bin/isql

COMMAND_TO_RUN=<<PUT YOUR QUERY HERE>>
DATABASE=$3
SERVER=$4

if [ "$DATABASE" != "" ]; then    # database name provided, use it
        DATABASE="use $DATABASE"
fi

if [ "$SERVER" = "" ]; then    # server not provided, use DSQUERY
        SERVER=$DSQUERY
else
        SERVER=`echo $SERVER | tr '[a-z]' '[A-Z]'`   # server provided, translate to uppercase
fi

## get the password for the server
PW=`/sybase_sa/bin/get_pw $SERVER`

## run the command
$ISQL_CMD -S$SERVER -Usa -w1000 <<EOF
$PW
set nocount on
go
$DATABASE
go
select @@servername, db_name(), convert(varchar,getdate(),109)
go
print ''
go
set nocount off
go
$COMMAND_TO_RUN
go
EOF

exit


Last edited by pludi; 10-28-2009 at 02:29 PM.. Reason: code tags, please...
# 2  
This doesn't seem to be a shell scripting question but more of a sybase question. Wouldn't you want to ask this on a sybase forum?
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #307
Difficulty: Easy
The common software-programming acronym 18N comes from the term Interlocalization;.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to solve query

Hi I have data in the below format in two columns in excel which i will copy to notepad. test as rec1, string test as rec2, byteint test as rec3, string update date as test, datetime name as tes2 string I need to add trim function on all the string columns and keep the remaining... (10 Replies)
Discussion started by: pisikar
10 Replies

2. Programming

Query result from shell script

Hi, I wrote the below script to get the query result from a Syabase DB. isql -s -U **** -P **** SYBASE SERVERNAME USE ***(Database name in Sybase) @command.sql But im not getting the output. Can anyone help me on this (2 Replies)
Discussion started by: rohan G
2 Replies

3. Red Hat

Sql query through shell script

hey , i am using this code to store value of a sql query and and then use it in other query but after some time , but it is not working. please help #!/bin/bash val_1=$( sqlplus -s rte/rted2@rel76d2 << EOF setting heading off select max(stat_id) from cvt_stats; exit EOF ) nohup... (5 Replies)
Discussion started by: ramsavi
5 Replies

4. Shell Programming and Scripting

Shell Script to execute Oracle query taking input from a file to form query

Hi, I need to query Oracle database for 100 users. I have these 100 users in a file. I need a shell script which would read this User file (one user at a time) & query database. For instance: USER CITY --------- ---------- A CITY_A B CITY_B C ... (2 Replies)
Discussion started by: DevendraG
2 Replies

5. Shell Programming and Scripting

shell script query

Hi Admins, I was trying to list the failed logins as part of my daily checklist. Here is my script for i in `who -s /etc/security/failedlogins|tail -100|grep "$dt"|awk '{print $1" "$6}'` do a=`echo $i|wc -l` if then echo $i else echo "There are no failed logins" fi done but... (3 Replies)
Discussion started by: newaix
3 Replies

6. Shell Programming and Scripting

Query Oracle tables and return values to shell script that calls the query

Hi, I have a requirement as below which needs to be done viz UNIX shell script (1) I have to connect to an Oracle database (2) Exexute "SELECT field_status from table 1" query on one of the tables. (3) Based on the result that I get from point (2), I have to update another table in the... (6 Replies)
Discussion started by: balaeswari
6 Replies

7. Shell Programming and Scripting

query sql using shell script

query sql using shell script, is it possible? my friend told me to do a file.sql and link to my shell script, but can i query sql using shell script? thanks in advance! (2 Replies)
Discussion started by: kingpeejay
2 Replies

8. UNIX for Dummies Questions & Answers

Shell script query

Hi, I am stuck assigning a value to a variable. I am trying to assign a value to a variable but getting error.... IP_ADDR=grep 'I.P. Address' /install/cfgdist/`uname -n`.cfg | cut -d : -f 2| cut -d . -f 1-3| sed s/" "//g I am using this script to grep first three octets of an IP address... (4 Replies)
Discussion started by: max29583
4 Replies

9. Shell Programming and Scripting

C Shell Script query

Hi I need a small help Cshell% more abc.txt ******** Cshell% cat abc.txt | cut -c1-3 *** Cshell%set test3=`cat abc.txt | cut -c1-3` Cshell%echo $test3 a.txt b.txt................. ..... It displays all the file in the current directory. I want *** to be displayed. Can any one of... (1 Reply)
Discussion started by: bpupdown
1 Replies

10. Shell Programming and Scripting

shell script related query

Hi I have an input to a file. I want the script to return it formatted the input is a number, say , 1234567895 and the output should be 21 43 65 87 59 ,ie, the pair of two digits should be reversed. How can I do this using a shell script? (1 Reply)
Discussion started by: gopsman
1 Replies

Featured Tech Videos