189 8069 5689

包含linuxtell命令的词条

在window环境和Linux环境下怎么用PHP连接oracle数据库,具体的步骤怎么做?怎么加载模块?加载哪些模块?

windows和Linux都能执行

专注于为中小企业提供成都网站制作、做网站服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业西平免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了超过千家企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。

Oracle Call Interface(OCI)使用户可以访问 Oracle 10,Oracle9,Oracle8 和 Oracle7 数据库。支持将 PHP 变量与 Oracle 占位符(placeholder)绑定,具有完整的 LOB,FILE 和 ROWID 支持,以及允许使用用户提供的定义变量。

例子 1. 基本查询

?php

$conn = oci_connect('hr', 'hr', 'orcl');

if (!$conn) {

$e = oci_error();

print htmlentities($e['message']);

exit;

}

$query = 'SELECT * FROM DEPARTMENTS';

$stid = oci_parse($conn, $query);

if (!$stid) {

$e = oci_error($conn);

print htmlentities($e['message']);

exit;

}

$r = oci_execute($stid, OCI_DEFAULT);

if(!$r) {

$e = oci_error($stid);

echo htmlentities($e['message']);

exit;

}

print 'table border="1"';

while($row = oci_fetch_array($stid, OCI_RETURN_NULLS)) {

print 'tr';

foreach($row as $item) {

print 'td'.($item?htmlentities($item):' ').'/td';

}

print '/tr';

}

print '/table';

oci_close($conn);

?

例子 2. 用绑定变量插入

?php

// Before running, create the table:

// CREATE TABLE MYTABLE (mid NUMBER, myd VARCHAR2(20));

$conn = oci_connect('scott', 'tiger', 'orcl');

$query = 'INSERT INTO MYTABLE VALUES(:myid, :mydata)';

$stid = oci_parse($conn, $query);

$id = 60;

$data = 'Some data';

oci_bind_by_name($stid, ':myid', $id);

oci_bind_by_name($stid, ':mydata', $data);

$r = oci_execute($stid);

if($r)

print "One row inserted";

oci_close($conn);

?

例子 3. 将数据插入到 CLOB 列中

?php

// Before running, create the table:

// CREATE TABLE MYTABLE (mykey NUMBER, myclob CLOB);

$conn = oci_connect('scott', 'tiger', 'orcl');

$mykey = 12343; // arbitrary key for this example;

$sql = "INSERT INTO mytable (mykey, myclob)

VALUES (:mykey, EMPTY_CLOB())

RETURNING myclob INTO :myclob";

$stid = oci_parse($conn, $sql);

$clob = oci_new_descriptor($conn, OCI_D_LOB);

oci_bind_by_name($stid, ":mykey", $mykey, 5);

oci_bind_by_name($stid, ":myclob", $clob, -1, OCI_B_CLOB);

oci_execute($stid, OCI_DEFAULT);

$clob-save("A very long string");

oci_commit($conn);

// Fetching CLOB data

$query = 'SELECT myclob FROM mytable WHERE mykey = :mykey';

$stid = oci_parse ($conn, $query);

oci_bind_by_name($stid, ":mykey", $mykey, 5);

oci_execute($stid, OCI_DEFAULT);

print 'table border="1"';

while ($row = oci_fetch_array($stid, OCI_ASSOC)) {

$result = $row['MYCLOB']-load();

print 'trtd'.$result.'/td/tr';

}

print '/table';

?

可以很容易地访问存储过程,就和从命令行访问一样。 例子 4. 使用存储过程

?php

// by webmaster at remoterealty dot com

$sth = oci_parse($dbh, "begin sp_newaddress( :address_id, '$firstname',

'$lastname', '$company', '$address1', '$address2', '$city', '$state',

'$postalcode', '$country', :error_code );end;");

// This calls stored procedure sp_newaddress, with :address_id being an

// in/out variable and :error_code being an out variable.

// Then you do the binding:

oci_bind_by_name($sth, ":address_id", $addr_id, 10);

oci_bind_by_name($sth, ":error_code", $errorcode, 10);

oci_execute($sth);

?

连接处理

OCI8 扩展提供了 3 个不同函数来连接 Oracle。取决于用户来使用对自己的应用程序最合适的函数。本节的信息有助于用户作出合适的选择。

连接到 Oracle 服务器从所需的时间上来讲是个相当花费的操作。oci_pconnect() 函数使用了一个连接的持久缓冲区,可以被不同的脚本请求重复使用。这意味着通常在每个 PHP 进程(或 Apache 子进程)中只需要连接一次。

如果应用程序连接 Oracle 时对每个 web 用户都使用了不同的认证信息,则由 oci_pconnect() 使用的持久缓冲区就用处不大了,因为随着并发用户的增加,到某个程度后会由于要保持太多的空闲连接而对 Oracle 服务器的整体性能起到逆反的影响。如果应用程序是这样的架构,建议要么用 oci8.max_persistent 和 oci8.persistent_timeout 配置选项(此二者可以使用户控制持久连接缓冲区的大小和生命周期)来协调应用程序,要么用 oci_connect() 来连接。

oci_connect() 和 oci_pconnect() 都使用了一个连接缓冲区。如果在某个脚本中用同样的参数多次调用 oci_connect(),则第二个和之后的调用会返回已有的连接句柄。oci_connect() 使用的连接缓冲区会在脚本执行完毕后或者明确地关闭了连接句柄时被清空。oci_pconnect() 有相似的行为,不过其缓冲区独立地维持着并在不同请求之间都存活着。

要记住此缓冲特性,因为它使两个句柄没有在事务级隔离开来(事实上是同一个连接句柄,因此没有任何方式的隔离)。如果应用程序需要两个独立的,事务级隔离的连接,应该使用 oci_new_connect()。

oci_new_connect() 总是创建一个到 Oracle 服务器的新连接,不管其它连接是否已经存在。高流量的 web 应用应该避免使用 oci_new_connect(),尤其是在程序最忙的部分。

有关于它的其他函数:

目录

OCI-Collection-append -- 向 collection 增加单元

OCI-Collection-assign -- 从现有的另一个 collection 向 collection 赋值

OCI-Collection-assignElem -- 给 collection 中的单元赋值

OCI-Collection-free -- 释放关联于 collection 的对象的资源

OCI-Collection-getElem -- 返回单元的值

OCI-Collection-max -- 返回 collection 中单元的最大数目

OCI-Collection-size -- 返回 collection 中的单元数目

OCI-Collection-trim -- 从 collection 尾端开始删除单元

OCI-Lob-append -- Appends data from the large object to another large object

OCI-Lob-close -- 关闭 LOB 描述符

OCI-Lob-eof -- Tests for end-of-file on a large object's descriptor

OCI-Lob-erase -- Erases a specified portion of the internal LOB data

OCI-Lob-export -- 将 LOB 的内容导出到文件中

OCI-Lob-flush -- Flushes/writes buffer of the LOB to the server

OCI-Lob-free -- 释放与 LOB 描述符所关联的资源

OCI-Lob-getBuffering -- Returns current state of buffering for the large object

OCI-Lob-import -- 将数据从文件导入 LOB

OCI-Lob-load -- 返回大对象的内容

OCI-Lob-read -- Reads part of the large object

OCI-Lob-rewind -- Moves the internal pointer to the beginning of the large object

OCI-Lob-save -- 将数据保存到大对象中

OCI-Lob-seek -- Sets the internal pointer of the large object

OCI-Lob-setBuffering -- Changes current state of buffering for the large object

OCI-Lob-size -- Returns size of large object

OCI-Lob-tell -- Returns current position of internal pointer of large object

OCI-Lob-truncate -- Truncates large object

OCI-Lob-write -- Writes data to the large object

OCI-Lob-writeTemporary -- 写入一个临时的大对象

oci_bind_by_name -- 绑定一个 PHP 变量到一个 Oracle 位置标志符

oci_cancel -- 取消从游标读取数据

oci_close -- 关闭 Oracle 连接

oci_commit -- 提交未执行的事务处理

oci_connect -- 建立一个到 Oracle 服务器的连接

oci_define_by_name -- 在 SELECT 中使用 PHP 变量作为定义的步骤

oci_error -- 返回上一个错误

oci_execute -- 执行一条语句

oci_fetch_all -- 获取结果数据的所有行到一个数组

oci_fetch_array -- Returns the next row from the result data as an associative or numeric array, or both

oci_fetch_assoc -- Returns the next row from the result data as an associative array

oci_fetch_object -- Returns the next row from the result data as an object

oci_fetch_row -- Returns the next row from the result data as a numeric array

oci_fetch -- Fetches the next row into result-buffer

oci_field_is_null -- 检查字段是否为 NULL

oci_field_name -- 返回字段名

oci_field_precision -- 返回字段精度

oci_field_scale -- 返回字段范围

oci_field_size -- 返回字段大小

oci_field_type_raw -- 返回字段的原始 Oracle 数据类型

oci_field_type -- 返回字段的数据类型

oci_free_statement -- 释放关联于语句或游标的所有资源

oci_internal_debug -- 打开或关闭内部调试输出

oci_lob_copy -- Copies large object

oci_lob_is_equal -- Compares two LOB/FILE locators for equality

oci_new_collection -- 分配新的 collection 对象

oci_new_connect -- 建定一个到 Oracle 服务器的新连接

oci_new_cursor -- 分配并返回一个新的游标(语句句柄)

oci_new_descriptor -- 初始化一个新的空 LOB 或 FILE 描述符

oci_num_fields -- 返回结果列的数目

oci_num_rows -- 返回语句执行后受影响的行数

oci_parse -- 配置 Oracle 语句预备执行

oci_password_change -- 修改 Oracle 用户的密码

oci_pconnect -- 使用一个持久连接连到 Oracle 数据库

oci_result -- 返回所取得行中字段的值

oci_rollback -- 回滚未提交的事务

oci_server_version -- 返回服务器版本信息

oci_set_prefetch -- 设置预提取行数

oci_statement_type -- 返回 OCI 语句的类型

ocibindbyname -- oci_bind_by_name() 的别名

ocicancel -- oci_cancel() 的别名

ocicloselob -- OCI-Lob-close 的别名

ocicollappend -- OCI-Collection-append 的别名

ocicollassign -- OCI-Collection-assign 的别名

ocicollassignelem -- OCI-Collection-assignElem 的别名

ocicollgetelem -- OCI-Collection-getElem 的别名

ocicollmax -- OCI-Collection-max 的别名

ocicollsize -- OCI-Collection-size 的别名

ocicolltrim -- OCI-Collection-trim 的别名

ocicolumnisnull -- oci_field_is_null() 的别名

ocicolumnname -- oci_field_name() 的别名

ocicolumnprecision -- oci_field_precision() 的别名

ocicolumnscale -- oci_field_scale() 的别名

ocicolumnsize -- oci_field_size() 的别名

ocicolumntype -- oci_field_type() 的别名

ocicolumntyperaw -- oci_field_type_raw() 的别名

ocicommit -- oci_commit() 的别名

ocidefinebyname -- oci_define_by_name() 的别名

ocierror -- oci_error() 的别名

ociexecute -- oci_execute() 的别名

ocifetch -- oci_fetch() 的别名

ocifetchinto -- 获取下一行到一个数组

ocifetchistatement -- oci_fetch_all() 的别名

ocifreecollection -- OCI-Collection-free 的别名

ocifreecursor -- oci_free_statement() 的别名

ocifreedesc -- OCI-Lob-free 的别名

ocifreestatement -- oci_free_statement() 的别名

ociinternaldebug -- oci_internal_debug() 的别名

ociloadlob -- OCI-Lob-load 的别名

ocilogoff -- oci_close() 的别名

ocilogon -- oci_connect() 的别名

ocinewcollection -- oci_new_collection() 的别名

ocinewcursor -- oci_new_cursor() 的别名

ocinewscriptor -- oci_new_descriptor() 的别名

ocinlogon -- oci_new_connect() 的别名

ocinumcols -- oci_num_fields() 的别名

ociparse -- oci_parse() 的别名

ociplogon -- oci_pconnect() 的别名

ociresult -- oci_result() 的别名

ocirollback -- oci_rollback() 别名

ocirowcount -- oci_num_rows() 的别名

ocisavelob -- OCI-Lob-save 的别名

ocisavelobfile -- OCI-Lob-import 的别名

ociserverversion -- oci_server_version() 的别名

ocisetprefetch -- oci_set_prefetch() 的别名

ocistatementtype -- oci_statement_type() 的别名

ociwritelobtofile -- OCI-Lob-export 的别名

ociwritetemporarylob -- OCI-Lob-writeTemporary 的别名

Linux操作系统下Sudo命令的使用方法

建议:

在Linux系统下,右键打开终端后,可以输入"man sudo"或者"info sudo"查询,因为使用方法实在是太多,可以摘要如下,其他可以自己查看。

NAME

sudo, sudoedit - execute a command as another user

SYNOPSIS

sudo -h | -K | -k | -L | -l | -V | -v

sudo [-bEHPS] [-p prompt] [-u username|#uid] [VAR=value]

{-i | -s | command}

sudoedit [-S] [-p prompt] [-u username|#uid] file ...

OPTIONS

sudo accepts the following command line options:

-b The -b (background) option tells sudo to run the given command in

the background. Note that if you use the -b option you cannot use

shell job control to manipulate the process.

-E The -E (preserve environment) option will override the env_reset

option in sudoers(5)). It is only available when either the

matching command has the SETENV tag or the setenv option is set in

sudoers(5).

-e The -e (edit) option indicates that, instead of running a command,

the user wishes to edit one or more files. In lieu of a command,

the string "sudoedit" is used when consulting the sudoers file. If

the user is authorized by sudoers the following steps are taken:

1. Temporary copies are made of the files to be edited with the

owner set to the invoking user.

2. The editor specified by the VISUAL or EDITOR environment vari-

ables is run to edit the temporary files. If neither VISUAL

nor EDITOR are set, the program listed in the editor sudoers

variable is used.

3. If they have been modified, the temporary files are copied back

to their original location and the temporary versions are

removed.

If the specified file does not exist, it will be created. Note

that unlike most commands run by sudo, the editor is run with the

invoking user's environment unmodified. If, for some reason, sudo

is unable to update a file with its edited version, the user will

receive a warning and the edited copy will remain in a temporary

file.

-H The -H (HOME) option sets the HOME environment variable to the

homedir of the target user (root by default) as specified in

passwd(5). By default, sudo does not modify HOME (see set_home and

always_set_home in sudoers(5)).

-h The -h (help) option causes sudo to print a usage message and exit.

-i The -i (simulate initial login) option runs the shell specified in

the passwd(5) entry of the user that the command is being run as.

The command name argument given to the shell begins with a '-' to

tell the shell to run as a login shell. sudo attempts to change to

that user's home directory before running the shell. It also ini-

tializes the environment, leaving TERM unchanged, setting HOME,

SHELL, USER, LOGNAME, and PATH, and unsetting all other environment

variables. Note that because the shell to use is determined before

the sudoers file is parsed, a runas_default setting in sudoers will

specify the user to run the shell as but will not affect which

shell is actually run.

-K The -K (sure kill) option is like -k except that it removes the

user's timestamp entirely. Like -k, this option does not require a

password.

-k The -k (kill) option to sudo invalidates the user's timestamp by

setting the time on it to the Epoch. The next time sudo is run a

password will be required. This option does not require a password

and was added to allow a user to revoke sudo permissions from a

.logout file.

-L The -L (list defaults) option will list out the parameters that may

be set in a Defaults line along with a short description for each.

This option is useful in conjunction with grep(1).

-l The -l (list) option will list out the allowed (and forbidden) com-

mands for the invoking user on the current host.

-P The -P (preserve group vector) option causes sudo to preserve the

invoking user's group vector unaltered. By default, sudo will ini-

tialize the group vector to the list of groups the target user is

in. The real and effective group IDs, however, are still set to

match the target user.

-p The -p (prompt) option allows you to override the default password

prompt and use a custom one. The following percent ('%') escapes

are supported:

%H expanded to the local hostname including the domain name (on if

the machine's hostname is fully qualified or the fqdn sudoers

option is set)

%h expanded to the local hostname without the domain name

%p expanded to the user whose password is being asked for

(respects the rootpw, targetpw and runaspw flags in sudoers)

%U expanded to the login name of the user the command will be run

as (defaults to root)

%u expanded to the invoking user's login name

%% two consecutive % characters are collapsed into a single %

character

-S The -S (stdin) option causes sudo to read the password from the

standard input instead of the terminal device.

-s The -s (shell) option runs the shell specified by the SHELL envi-

ronment variable if it is set or the shell as specified in

passwd(5).

-u The -u (user) option causes sudo to run the specified command as a

user other than root. To specify a uid instead of a username, use

#uid. When running commands as a uid, many shells require that the

'#' be escaped with a backslash ('\'). Note that if the targetpw

Defaults option is set (see sudoers(5)) it is not possible to run

commands with a uid not listed in the password database.

-V The -V (version) option causes sudo to print the version number and

exit. If the invoking user is already root the -V option will

print out a list of the defaults sudo was compiled with as well as

the machine's local network addresses.

-v If given the -v (validate) option, sudo will update the user's

timestamp, prompting for the user's password if necessary. This

extends the sudo timeout for another 5 minutes (or whatever the

timeout is set to in sudoers) but does not run a command.

-- The -- flag indicates that sudo should stop processing command line

arguments. It is most useful in conjunction with the -s flag.

Environment variables to be set for the command may also be passed on

the command line in the form of VAR=value, e.g.

LD_LIBRARY_PATH=/usr/local/pkg/lib. Variables passed on the command

line are subject to the same restrictions as normal environment vari-

ables with one important exception. If the setenv option is set in

sudoers, the command to be run has the SETENV tag set or the command

matched is ALL, the user may set variables that would overwise be for-

bidden. See sudoers(5) for more information.

linux终端命令的使用

shutdown

功能说明:系统关机命令

语法:shutdown [-t sec] [-arkhncfFHP] time [warning-message]

包名称:SysVinit

相关命令:halt,reboot

补充说明:本命令可以关闭所有的程序,并依用户的需要,进行重新开机或关机的操作。Shutdown命令可以指定系统在特定时间关机,但仅限于当日。若需指定在特定日期关机,则需搭配at命令执行。

参数:

-a

Use /etc/shutdown.allow.

-t sec

Tell init(8) to wait sec seconds between sending processes the warning and the kill signal, before changing to another runlevel.

-k

Don't really shutdown; only send the warning messages to everybody.

-r

Reboot after shutdown.

-h

Halt or poweroff after shutdown.

-H

Halt action is to halt or drop into boot monitor on systems that support it.

-P

Halt action is to turn off the power.

-n

[DEPRECATED] Don't call init(8) to do the shutdown but do it ourself. The use of this option is discouraged, and its results are not always what you'd expect.

-f

Skip fsck on reboot.

-F

Force fsck on reboot.

-c

Cancel an already running shutdown. With this option it is of course not possible to give the time argument, but you can enter a explanatory message on the command line that will be sent to all users.

time

When to shutdown.

warning-message

Message to send to all users.

范例:

1)立即关闭系统:

# shutdown -h now

2)执定在21:10将系统重新开机:

# shutdown -r 21:10

3)指定10分钟后关机,并发送警告信息:

# shutdown +10 “conputer will shut down”

4)取消关机:

# shutdown -c

Linux操作系统下Sudo命令的使用方法?

名称:sudo

使用权限:在 /etc/sudoers 中有出现的使用者

使用方式:sudo -V

sudo -h

sudo -l

sudo -v

sudo -k

sudo -s

sudo -H

sudo [ -b ] [ -p prompt ] [ -u username/#uid] -s

sudo command

说明:以系统管理者的身份执行指令,也就是说,经由 sudo 所执行的指令就好像是 root 亲自执行

参数:

-V 显示版本编号

-h 会显示版本编号及指令的使用方式说明

-l 显示出自己(执行 sudo 的使用者)的权限

-v 因为 sudo 在第一次执行时或是在 N 分钟内没有执行(N 预设为五)会问密码,这个参数是重新做一次确认,如果超过 N 分钟,也会问密码

-k 将会强迫使用者在下一次执行 sudo 时问密码(不论有没有超过 N 分钟)

-b 将要执行的指令放在背景执行

-p prompt 可以更改问密码的提示语,其中 %u 会代换为使用者的帐号名称, %h 会显示主机名称

-u username/#uid 不加此参数,代表要以 root 的身份执行指令,而加了此参数,可以以 username 的身份执行指令(#uid 为该 username 的使用者号码)

-s 执行环境变数中的 SHELL 所指定的 shell ,或是 /etc/passwd 里所指定的 shell

-H 将环境变数中的 HOME (家目录)指定为要变更身份的使用者家目录(如不加 -u 参数就是系统管理者 root )

command 要以系统管理者身份(或以 -u 更改为其他人)执行的指令

范例:

sudo -l 列出目前的权限

sudo -V 列出 sudo 的版本资讯

如何在Linux中发现IP地址冲突

下面我们来看一个实例:

一台linux主机 IP:192.168.0.25 MAC: 00:14:k2:5d:8e:b2

一台windows主机 IP:192.168.0.25 MAC: 00:25:e4:6a:4b:f4

两台主机的IP地址相同(IP:192.168.0.25),MAC地址不同

则windows主机会提示IP地址冲突,而linux主机无任何提示

那么如何知道自己的linux主机是否与网络中其它的windows主机IP地址冲突呢?

其实很简单,在linux主机端执行

#arping 192.168.0.25

Unicast reply from 192.168.0.25 [00:25:e4:6a:4b:f4] 1.390ms

如果没有任何信息,则表示网内我的IP是唯一的

如果有以上信息,则表示网内有一台MAC地址为00:25:e4:6a:4b:f4的主机IP地址与我相同,这时可以通过ifconfig命令验

证,你会发现:本机的MAC地址是00:14:k2:5d:8e:b2。我们可以用局域网扫描软件找到MAC地址为00:25:e4:6a:4b:f4的

主机,并将其隔离或更换IP地址。

原理:arping命令是以广播地址发送arp packets,以太网内所有的主机都会收到这个arp packets,但是本机收到之后不会Reply任何信息。当我们在linux主机端上执行下面的命令时:

arping 192.168.0.25会默认使用eth0,向局域网内所有的主机发送一个:

who has 192.168.0.25的arp request,tell 192.168.0.25 your mac address,

当这台windows主机端收到这个arp packets后,则会应答:

"I am 192.168.0.25 , mac是00:25:e4:6a:4b:f4",这样我们会收到mac地址为00:25:e4:6a:4b:f4的windows主机的Reply信息。

linux什么命令启服务

1、service命令

service命令其实是去/etc/init.d目录下,去执行相关程序

查看/etc/init.d目录下有哪些文件

[root@VM_0_11_centos init.d]# ll /etc/init.d/

total 40

-rw-r--r-- 1 root root 18281 Mar 29 2019 functions

-rwxr-xr-x 1 root root 4569 Mar 29 2019 netconsole

-rwxr-xr-x 1 root root 7923 Mar 29 2019 network

-rw-r--r-- 1 root root 1160 Oct 19 00:48 README

[root@VM_0_11_centos init.d]#

查看脚本文件都有哪些命令

# See how we were called.

case "$1" in

start)

[ "$EUID" != "0" ] exit 4

rc=0

# IPv6 hook (pre IPv4 start)

if [ -x /etc/sysconfig/network-scripts/init.ipv6-global ]; then

/etc/sysconfig/network-scripts/init.ipv6-global start pre

fi

apply_sysctl

#tell NM to reload its configuration

[root@VM_0_11_centos ~]# /etc/init.d/network start

Starting network (via systemctl): [ OK ]

[root@VM_0_11_centos ~]# service restart network

The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.

[root@VM_0_11_centos ~]#

2、systemctl命令

systemd是Linux系统最新的初始化系统(init),作用是提高系统的启动速度,尽可能启动较少的进程,尽可能更多进程并发启动。

systemd对应的进程管理命令是systemctl


网站名称:包含linuxtell命令的词条
分享URL:http://cdxtjz.cn/article/hsighj.html

其他资讯