① linux C/C++ proc 連接oracle 求教
/*
* sample2.pc
*
* This program connects to ORACLE, declares and opens a cursor,
* fetches the names, salaries, and commissions of all
* salespeople, displays the results, then closes the cursor.
*/
#include <stdio.h>
#include <sqlca.h>
#define UNAME_LEN 20
#define PWD_LEN 40
/*
* Use the precompiler typedef』ing capability to create
* null-terminated strings for the authentication host
* variables. (This isn』t really necessary--plain char *』s
* does work as well. This is just for illustration.)
*/
typedef char asciiz[PWD_LEN];
EXEC SQL TYPE asciiz IS STRING(PWD_LEN) REFERENCE;
asciiz username;
asciiz password;
struct emp_info
{
asciiz emp_name;
float salary;
float commission;
};
/* Declare function to handle unrecoverable errors. */
void sql_error();
main()
{
struct emp_info *emp_rec_ptr;
/* Allocate memory for emp_info struct. */
if ((emp_rec_ptr =
(struct emp_info *) malloc(sizeof(struct emp_info))) == 0)
{
fprintf(stderr, "Memory allocation error.\n");
exit(1);
}
/* Connect to ORACLE. */
strcpy(username, "SCOTT");
strcpy(password, "TIGER");
EXEC SQL WHENEVER SQLERROR DO sql_error("ORACLE error--");
EXEC SQL CONNECT :username IDENTIFIED BY :password;
printf("\nConnected to ORACLE as user: %s\n", username);
/* Declare the cursor. All static SQL explicit cursors
* contain SELECT commands. 』salespeople』 is a SQL identifier,
* not a (C) host variable.
*/
EXEC SQL DECLARE salespeople CURSOR FOR
SELECT ENAME, SAL, COMM FROM EMP WHERE JOB LIKE 』SALES%』;
/* Open the cursor. */
EXEC SQL OPEN salespeople;
/* Get ready to print results. */
printf("\n\nThe company』s salespeople are--\n\n");
printf("Salesperson Salary Commission\n");
printf("----------- ------ ----------\n");
/* Loop, fetching all salesperson』s statistics.
* Cause the program to break the loop when no more
* data can be retrieved on the cursor.
*/
EXEC SQL WHENEVER NOT FOUND DO break;
for (;;)
{
EXEC SQL FETCH salespeople INTO :emp_rec_ptr;
printf("%-11s%9.2f%13.2f\n", emp_rec_ptr->emp_name,emp_rec_ptr->salary, emp_rec_ptr->commission);
}
/* Close the cursor. */
EXEC SQL CLOSE salespeople;
printf("\nArrivederci.\n\n");
EXEC SQL COMMIT WORK RELEASE;
exit(0);
}
void sql_error(msg) char *msg;
{
char err_msg[512];
int buf_len, msg_len;
EXEC SQL WHENEVER SQLERROR CONTINUE;
printf("\n%s\n", msg);
/* Call sqlglm() to get the complete text of the
* error message.
*/
buf_len = sizeof (err_msg);
sqlglm(err_msg, &buf_len, &msg_len);
printf("%.*s\n", msg_len, err_msg);
EXEC SQL ROLLBACK RELEASE;
exit(1);
}
② linux下at命令詳解
linuxmount-a命令詳解?
1、功能:
載入指定的文件系統;mount可將指定設備中指定的文件系統載入到Linux目錄下(也就是掛載點)。可將經常使用的設備寫入文件/etc/fastab,以使系統在每次啟動時自動載入。mount載入設備的信息記錄在/etc/mtab文件中。使用umount命令卸載設備時,記錄將被清除。
2、用法:
mount
mount
mount
3、參數:
1.-a載入文件/etc/fstab中設置的所有設備。
2.-f不實際載入設備。可與-v等參數同時使用以查看mount的執行過程。
3.-F需與-a參數同時使用。所有在/etc/fstab中設置的設備會被同時載入,可加快執行速度。
4.-h顯示在線幫助信息。
5.-L標簽>載入文件系統標簽為標簽>的設備。
6.-n不將載入信息記錄在/etc/mtab文件中。
7.-o選項>指定載入文件系統時的選項。有些選項也可在/etc/fstab中使用。這些選項包括:
async以非同步的方式執行文件系統的輸入輸出動作。默認是async
sync以同步的方式執行文件系統的輸入輸出動作。
atime每次存取都更新inode的存取時間,默認設置,取消選項為noatime。
noatime每次存取時不更新inode的存取時間。
auto必須在/etc/fstab文件中指定此選項。執行-a參數時,會載入設置為auto的設備,取消選取為noauto。
noauto無法使用-a參數來載入。
dev,nodev是否允許此文件系統可建立設備文件?dev為允許
suid,nosuid是否允許此文件系統含有suid/sgid的文件格式
exec,noexec是否允許此文件系統上擁有可執行二進制文件
user,nouser是否允許此文件系統上任何使用者執行mount?一般來說,mount僅有root可以執行,但執行user參數,則可讓一般用戶user也能夠對此分區進行mount
defaults使用默認的選項。默認選項為rw、suid、dev、exec、autonouser與async。
nouser使一位用戶無法執行載入操作,默認設置。
remount重新載入設備。通常用於改變設備的設置狀態。
ro以只讀模式載入。
rw以可讀寫模式載入。
8.-r以只讀方式載入設備。
9.-t文件系統類型>指定設備的文件系統類型。常用的選項說明有:
minixLinux最早使用的文件系統。
ext2Linux目前的常用文件系統。
msdosMS-DOS的FAT。
vfatWin85/98的VFAT。
nfs網路文件系統。
iso9660CD-ROM光碟的標准文件系統。
ntfsWindowsNT的文件系統。
hpfsOS/2文件系統。WindowsNT3.51之前版本的文件系統。
auto自動檢測文件系統。
10.-v執行時顯示詳細的信息。
11.-V顯示版本信息。
12.-w以可讀寫模式載入設備,默認設置。
什麼是AT工程師?
主要進行網路工程的設計等。
AT工程師的崗位職責
1.能夠在linux系統下做開發;
2.最好可以對AT命令有了解;
3.能夠做串口開發;
4.負責產品底層處理需求分析,設計和開發;
工程師指具有從事工程系統操作、設計、管理、評估能力的人員。工程師的稱謂,通常只用於在工程學其中一個范疇持有專業性學位或相等工作經驗的人士。
linuxdmesg命令詳解?
linuxdmesg命令參數及用法詳解(linux顯示開機信息命令)
功能說明:顯示開機信息。
語法:dmesg
補充說明:kernel會將開機信息存儲在ringbuffer中。您若是開機時來不及查看信息,可利用dmesg來查看。開機信息亦保存在/var/log目錄中,名稱為dmesg的文件里。
參數:
-c顯示信息後,清除ringbuffer中的內容。
-s緩沖區大小>預設置為8196,剛好等於ringbuffer的大小。
-n設置記錄信息的層級。擴展閱讀一:dmesg命令主要用途
主要應用:
dmesg用來顯示內核環緩沖區(kernel-ringbuffer)內容,內核將各種消息存放在這里。在系統引導時,內核將與硬體和模塊初始化相關的信息填到這個緩沖區中。內核環緩沖區中的消息對於診斷系統問題通常非常有用。在運行dmesg時,它顯示大量信息。通常通過less或grep使用管道查看dmesg的輸出,這樣可以更容易找到待查信息。例如,如果發現硬碟性能低下,可以使用dmesg來檢查它們是否運行在DMA模式:
$dmesg|grepDMA
...
ide0:BM-DMAat0xf000-0xf007,BIOSsettings:hda:DMA,hdb:DMA
ide1:BM-DMAat0xf008-0xf00f,BIOSsettings:hdc:DMA,hdd:DMA
...上面幾行可以說明每個IDE設備正在什麼模式下運行。如果乙太網連接出現問題,那麼可以在dmesg日誌中搜索eth:
$dmesg|grepeth
forcedeth.c:ReverseEngineerednForce
ethernetdriver.Version0.49.
eth0:forcedeth.c:subsystem:0147b:1c00
boundto0000:00:04.0
eth0:noIPv6routerspresent如果一切正常,那麼dmesg顯示每個網卡的硬體配置信息。如果某項系統服務未能得到正確的配置,dmesg日誌很快就填滿錯誤消息,這是診斷故障的良好起點。
還可以用來探測系統內核模塊的載入情況,比如要檢測ACPI的載入情況,使用dmesg|grepacpi
dmesg|egrep-i''(apm|acpi)''
Kernelcommandline:vga=274quietconsole=ttyS3,9600acpi=no-idleoot=/dev/hda3
ACPI:CoreSubsystemversion
ACPI:Subsystemenabled
ACPI:Systemfirmwaresupports:C2
ACPI:plvl2lat=99plvl3lat=1001
ACPI:C2enter=1417C2exit=354
ACPI:C3enter=-1C3exit=-1
ACPI:NotusingACPIidle
ACPI:Systemfirmwaresupports:S0S1S4S5
擴展閱讀二:dmesg命令使用示例
使用示例
示例一將開機信息發郵件
mandmesg寫道
.Insteadofingthemessagesbyhand,theuserneedonly:
dmesg>boot.messages
andmailtheboot..
#dmesg>boot.messages
#ls-lboot.messages
-rw-r--r--1rootroot1583812-0912begin_of_the_skype_highlighting
1583812-0912免費end_of_the_skype_highlighting:55boot.messages#mail-s"BootLogofLinuxServer"[email protected]
#示例二瀏覽dmesg輸出的信息
#uname-a
Linuxnew552.6.18-194.el5#1SMPTueMar1621:52:43EDT2010i686i686i386GNU/Linux#dmesg|less
Linuxversion2.6.18-194.el5([email protected])(gccversion4.1.220080704(RedHat4.1.2-48))#1SMPTueMar1621:52:43EDT2010
BIOS-providedphysicalRAMmap:
BIOS-e820:0000000000010000-000000000009fc00(usable)
BIOS-e820:000000000009fc00-00000000000a0000(reserved)
BIOS-e820:00000000000e0000-0000000000100000(reserved)
BIOS-e820:0000000000100000-000000001f7d0000(usable)
BIOS-e820:000000001f7d0000-000000001f7efc00(reserved)
BIOS-e820:000000001f7efc00-000000001f7fb000(ACPINVS)
BIOS-e820:000000001f7fb000-000000001f800000(reserved)
BIOS-e820:00000000e0000000-00000000f0000000(reserved)
BIOS-e820:00000000fec00000-00000000fec02000(reserved)
BIOS-e820:00000000fed20000-00000000fed9b000(reserved)
BIOS-e820:00000000feda0000-00000000fedc0000(reserved)
BIOS-e820:00000000ffb00000-00000000ffc00000(reserved)
BIOS-e820:00000000fff00000-0000000100000000(reserved)
0MBHIGHMEMavailable.
503MBLOWMEMavailable.
Memoryforcrashkernel(0x0to0x0)notwithinpermissiblerange
disablingkmp
Onnode0totalpages:128976
DMAzone:4096pages,LIFObatch:0
Normalzone:124880pages,LIFObatch:31
DMI2.3present.
UsingAPICdriverdefault
ACPI:RSDP(v000HP)@0x000fe270
ACPI:RSDT()@0x1f7efc84
ACPI:FADT()@0x1f7efc00
ACPI:MADT()@0x1f7efcb8
ACPI:MCFG()@0x1f7efd14
ACPI:SSDT()@0x1f7f6698
ACPI:DSDT()@0x00000000
ACPI:PM-TimerIOPort:0x1008
ACPI:LocalAPICaddress0xfec01000
ACPI:LAPIC(acpi_idlapic_idenabled)
Processor#06:13APICversion20
ACPI:LAPIC_NMI(acpi_idhighedgelint)
ACPI:IOAPIC(idaddressgsi_base)
IOAPIC:apic_id1,version32,address0xfec00000,GSI0-23
:
示例三查看dmesg尾部的信息
#dmesg|tail
Bluetooth:L2CAPver2.8
Bluetooth:L2CAPsocketlayerinitialized
Bluetooth:RFCOMMsocketlayerinitialized
Bluetooth:RFCOMMTTYlayerinitialized
Bluetooth:RFCOMMver1.8
Bluetooth:HIDP(HumanInterfaceEmulation)ver1.1
eth0:noIPv6routerspresent
Installingknfsd(right(C)[email protected]).
NFSD:Using/var/lib/nfs/
NFSD:starting90-secondgraceperiod
#
示例四安裝SS7卡驅動時的內核日誌
#cdSS7HD_DRIVER/
#ls
bbdddlnx_iss.hbbd_hbi.hbbd_ioc.cbbd_isr.cbbd_pci.cBSD_license.txtGPL_V2-only_license.txtinstall_ss7hd.shMakefile26
bbd_def.hbbd_hs.cbbd_ioc.hbbd_lnx.cbbd_pro.hbuild_ss7hd.shi21555.hMakefile24
#./build_ss7hd.sh
make:Enteringdirectory`/usr/src/kernels/2.6.9-22.EL-i686'
CC/root/setup/ss7dpklnx/SS7HD_DRIVER/bbd_hs.o
CC/root/setup/ss7dpklnx/SS7HD_DRIVER/bbd_ioc.o
CC/root/setup/ss7dpklnx/SS7HD_DRIVER/bbd_isr.o
CC/root/setup/ss7dpklnx/SS7HD_DRIVER/bbd_pci.o
CC/root/setup/ss7dpklnx/SS7HD_DRIVER/bbd_lnx.o
LD/root/setup/ss7dpklnx/SS7HD_DRIVER/ss7hddvr26.o
Buildingmoles,stage2.
MODPOST
CC/root/setup/ss7dpklnx/SS7HD_DRIVER/ss7hddvr26.mod.o
LD/root/setup/ss7dpklnx/SS7HD_DRIVER/ss7hddvr26.ko
make:Leavingdirectory`/usr/src/kernels/2.6.9-22.EL-i686'http://www.linuxso.com/command/dmesg.html#./install_ss7hd.sh
#lsmod|grepss7
ss7hddvr26258080
#dmesg|tail
ACPI:PCIinterrupt0000:02:0d.0->GSI9(level,low)->IRQ9
BBD64bit
SS7HD-suspend
DialogicSS7HDDeviceDriverV100.00(SourceV1.21)
Copyright(C)DialogicCorporation2003-2010.AllRightsReserved
Usingmajordevicenumber251.
ACPI:PCIinterrupt0000:02:0d.0->GSI9(level,low)->IRQ9
BBD64bit
#./install_ss7hd.shremove
#lsmod|grepss7
#dmesg|tail
BBD64bit
SS7HD-suspend
DialogicSS7HDDeviceDriverV100.00(SourceV1.21)
Copyright(C)DialogicCorporation2003-2010.AllRightsReserved
Usingmajordevicenumber251.
ACPI:PCIinterrupt0000:02:0d.0->GSI9(level,low)->IRQ9
BBD64bit
SS7HD-suspend
#
示例五列印並清除內核環形緩沖區
#dmesg-c
Linuxversion2.6.18-194.el5([email protected])(gccversion4.1.220080704(RedHat4.1.2-48))#1SMPTueMar1621:52:43EDT2010
BIOS-providedphysicalRAMmap:
BIOS-e820:0000000000010000-000000000009fc00(usable)
BIOS-e820:000000000009fc00-00000000000a0000(reserved)
BIOS-e820:00000000000e0000-0000000000100000(reserved)
BIOS-e820:0000000000100000-000000001f7d0000(usable)
BIOS-e820:000000001f7d0000-000000001f7efc00(reserved)
BIOS-e820:000000001f7efc00-000000001f7fb000(ACPINVS)
BIOS-e820:000000001f7fb000-000000001f800000(reserved)
BIOS-e820:00000000e0000000-00000000f0000000(reserved)
BIOS-e820:00000000fec00000-00000000fec02000(reserved)
BIOS-e820:00000000fed20000-00000000fed9b000(reserved)
BIOS-e820:00000000feda0000-00000000fedc0000(reserved)
BIOS-e820:00000000ffb00000-00000000ffc00000(reserved)
BIOS-e820:00000000fff00000-0000000100000000(reserved)
0MBHIGHMEMavailable.
503MBLOWMEMavailable.
Memoryforcrashkernel(0x0to0x0)notwithinpermissiblerange
disablingkmp
Onnode0totalpages:128976
DMAzone:4096pages,LIFObatch:0
Normalzone:124880pages,LIFObatch:31
DMI2.3present.省略輸出
Bluetooth:HIDP(HumanInterfaceEmulation)ver1.1
eth0:noIPv6routerspresent
Installingknfsd(right(C)[email protected]).
NFSD:Using/var/lib/nfs/
NFSD:starting90-secondgraceperiod
#dmesg#less/var/log/dmesg
Linuxversion2.6.18-194.el5([email protected])(gccversion4.1.220080704(RedHat4.1.2-48))#1SMPTueMar1621:52:43EDT2010
BIOS-providedphysicalRAMmap:
BIOS-e820:0000000000010000-000000000009fc00(usable)
BIOS-e820:000000