A shell script that converts hexadecimal to decimal. The principle is similar. It should be a bit like this. It is in the Solaris environment. It is used to convert the Sybase interfaces file under Solaris to the SQL. ini of Sybase in windows.
[Code: 1: 8fab55483b]
#! /Bin/sh
# This is a script to convert the interfaces file of sybase server to SQL. ini
Sybase client on PC.
# Define sion/ICIL
# Intialize SQL. ini
(
Echo "; Sybase Interfaces file"
Echo ";;"
Echo "; [<database_server_name>]"
Echo "; <link_type >=< network_driver>, <connection_info>"
Echo ";;"
Echo "; Examples :"
Echo "; [JUPITER]"
Echo "; QUERY = NLMSNMP, \ JUPITER \ pipe \ sybase \ query"
Echo "; WIN3_QUERY = WNLNMP, \ JUPITER \ pipe \ sybase \ query"
Echo "; \ n"
)>/Tmp/SQL
# May ignore the backup server for sybase
Servers = 'grep-I '^ [a-z]'/opt/sybase11/interfaces | sed '/_ BACKUP/d''
For server in $ {servers}; do
Echo "Converting $ {server} info ..."
Server_info = 'grep-A 2 \ ^ "$ {server}" \ $/opt/sybase11/interfaces'
Master_info = 'echo "$ {server_info}" | grep "master" | awk '{print $5 }''
# May use a perl script to convert the number of IP too.
Master_ip1 = 'echo "$ {master_info}" | cut-c11-12'
Master_ip1 = 'echo "$ {master_ip1}" | tr' [a-z] ''[A-Z]''
Master_ip1 = 'echo "obase = 10; ibase = 16; $ {master_ip1}" | bc'
Master_ip2 = 'echo "$ {master_info}" | cut-c13-14'
Master_ip2 = 'echo "$ {master_ip2}" | tr' [a-z] ''[A-Z]''
Master_ip2 = 'echo "obase = 10; ibase = 16; $ {master_ip2}" | bc'
Master_ip3 = 'echo "$ {master_info}" | cut-c15-16'
Master_ip3 = 'echo "$ {master_ip3}" | tr' [a-z] ''[A-Z]''
Master_ip3 = 'echo "obase = 10; ibase = 16; $ {master_ip3}" | bc'
Master_ip4 = 'echo "$ {master_info}" | cut-c17-18'
Master_ip4 = 'echo "$ {master_ip4}" | tr' [a-z] ''[A-Z]''
Master_ip4 = 'echo "obase = 10; ibase = 16; $ {master_ip4}" | bc'
Master_ip = 'echo "$ {master_ip1}. $ {master_ip2}. $ {master_ip3}. $ {master_ip4}
`
Master_port = 'echo "$ {master_info}" | cut-c7-10'
Master_port = 'echo "$ {master_port}" | tr '[a-z] ''[A-Z]''
Master_port = 'echo "obase = 10; ibase = 16; $ {master_port}" | bc'
# Add the server info to SQL. ini
(
Echo "[$ {server}]"
Echo "master = NLWNSCK, $ {master_ip}, $ {master_port }"
Echo "query = NLWNSCK, $ {master_ip}, $ {master_port} \ n"
)>/Tmp/SQL
Done
# Convert to PC filesystem
Unix2dos/tmp/SQL>/tmp/SQL. ini [/code: 1: 8fab55483b]