This post turned from: echoaix doodle home http://blog.chinaunix.net/u/10212/showart.php? Id = 88834
To the Sybase
Thank you.
The reason for converting the following content is to make a record to view how to modify the file content in UNIX. In Windows, it is easy to modify the data in the file in hexadecimal format. You can use ultraedit, a powerful tool. I have compiled a tool to extract data from the Sybase data device file and translate and parse the content of the Sybase Log Device File. In this process, UE provides great help. The tool I wrote has nothing to do with ue. However, sometimes I like to use ue when making a small modification to the Sybase device file.
But how can I modify the Sybase device file in UNIX? I can't download FTP files every time. I changed it with ultraedit in windows and then uploaded it to the server?
This is too troublesome.
Fortunately, experts have provided a solution! Amazing!
I have not fully understood the following code, mainly because the shell has not been written in UNIX.
It indicates that three parameters are passed to the sh script to replace the data of the same byte with the corresponding offset in the specified file with the specified data.
Use od to locate the modified offset. Then input data to dd Using echo. DD will process this file.
I didn't understand how to convert 4 bytes of data into the code in the array!
-----------------------------------------------------------------------------
Environment
:
Only this environment is available for ibm aix 4.3 and sybase11.9.
Master device/dev/rlvsybmaster1
See the page content as before:
DBCC traceon (3604)
Go
DBCC tablealloc (sysdatabases) or select first from sysindexes where id = object_id ("sysdatabases" and indid = 1 // locate the data page (pageno)
Go
DBCC page (master, pageno,) // obtain the details of this page from the hard disk
Go
The master is as follows:
Offset 266-
3256210a: 02000001 00010000 80000001 000008a1 ................
3256211a: 00000000 00000000 00009179 00fe9caa ....
3256212a: 0005 Adda 00120034 6d617374 65728000 ...... 4master ..
3256213a: 03302e28. 0 .(.
Use the OD command to locate (the OD command is good)
# OD-H/dev/lvsybmaster1 | grep '2017 02000001 00010000 000008a1'
The error message is not found. Depressed. Take a closer look at DBCC page usage 1 (print page header, data rows and row offset
Table), 2 (print page header and Hex dump of data page ). Use DBCC
Page (master, pageno, 2, 0)
The result is as follows:
32562110: 00008000 00010000 08a10000 00000000 ................
32562120: 00000000 917900fe 9caa0005 adda0012 ...... y ..........
32562130: 00127d61 73746572 80000330 2e280201. 4master... 0 .(..
32562140: 00030001 00000000 00010000 01e00000 ................
32562150: 00000000 00000000 917900fd acd60013 ...... y ......
32562160: 9866001e 00336d6f 64656c80 00032f2d. F... 3model .../-
It turns out that the order is different. No wonder grep cannot be found:
# OD-H/dev/lvsybmaster1 | grep '2017 00008000 08a10000 123' result
2024420 00008000 00010000 08a10000 00000000 found. Note that the offset is in octal format.
Find out how to change it? I know dd should be used for a long time.
In liveunix, I saw the post of "fried chicken" and gave the sh as follows:
Cat chvgid. Sh
#! /Usr/bin/KSh
Vgid = $1
Disk = $2
Set-A a' echo $ vgid |/
Awk
'{
For (F = 1; F <= length ($0); F = F + 2 ){
Print "IBASE = 16/nobase = 8/N" toupper (substr ($0, F, 2 ))
}
} '| BC 2>/dev/null'
/Usr/bin/echo "/0" $ {A [0]} "/0" $ {A [1]} "/0" $ {A [2]}" /0 "$ {A [3]}"/C "| dd BS = 1 seek = 3600 of =/dev/$ Disk
It turns out that he wants to directly change the vgid information. It seems that there are a lot of things that can be changed.
I still cannot understand this sh, but it's okay to use it. I changed it as follows.
# Cat chfile. Sh
#! /Usr/bin/KSh
Dstatus = $1
Filename = $2
Offset = $3
Set-A a' echo $ dstatus |/
Awk '{
For (F = 1; F <= length ($0); F = F + 2 ){
Print "IBASE = 16/nobase = 8/N" toupper (substr ($0, F, 2 ))
}
} '| BC 2>/dev/null'
/Usr/bin/echo "/0" $ {A [0]} "/0" $ {A [1]} "/0" $ {A [2]}" /0 "$ {A [3]}"/C "| dd BS = 1 seek = $ offset of = $ filename Conv = notrunc
The $3 offset is added, and conv = notrunc is added. Otherwise, the data after the point is modified may be gone. The offset is in decimal format.
Od-ad-H/dev/lvsybmaster1 | grep '2017 00008000 08a10000 100' returns a 10-digit offset.
0534800 00008000 00010000 08a10000 00000000
Disable Sybase
Change master device
# Chfile. Sh 00000000/dev/lvsybmaster1 534800
4 + 0 records in.
4 + 0 records out.
Is to change 00008000 to 00000000.
Restart Sybase OK
-----------------------------------------------------------------------------