Categories
php

在psftp中进行批处理操作

在psftp(sftp的命令行客户端)中进行批处理操作:

1.首先建立文件->myscript.scr,内容如下:

代码片段:


cd /home/ftp/users/jeff
del jam-old.tar.gz
ren jam.tar.gz jam-old.tar.gz
put jam.tar.gz
chmod a+r jam.tar.gz
quit

2.然后你可以运行下面命令行:

psftp user@hostname -b myscript.scr

myscript.scr中所写的内容就会执行下去

3.有什么用呢?在windows下写个批处理.bat,配合editplus上传文件,爽翻你

附命令行帮助:

代码片段:


PuTTY Secure File Transfer (SFTP) client
Release 0.56
Usage: psftp [options] [user@]host
Options:
  -b file   use specified batchfile
  -bc       output batchfile commands
  -be       don't stop batchfile processing if errors
  -v        show verbose messages
  -load sessname  Load settings from saved session
  -l user   connect with specified username
  -P port   connect to specified port
  -pw passw login with specified password
  -1 -2     force use of particular SSH protocol version
  -C        enable compression
  -i key    private key file for authentication
  -batch    disable all interactive prompts
  -V        print version information
Categories
common

新闻组上看到的mysql cluster安装过程

如下:

 I have recently had success setting up a MySQL Cluster, so I
thought I’d share what I did with everyone since it was such a challenge
for me to do and the documentation for how to set it up is so poor.
 

[@more@] 

######################### My Setup ####################################

Here is my setup:

I have two machines, Machine A and Machine B, that have requests and
updates to the db balanced by a router.  There is one IP address that
clients use to access the db.  The router distributes 50% of the
requests to Machine A and the remaining 50% to Machine B.  Therefore,
the db on both Machine A and Machine B must be exactly the same at all
times.  To achieve this I used MySQL Cluster.

 

I am running Redhat Linux 9 on both machines, and the machines are
physically identical.

 

Machine A ip = 10.0.2.39

Machine B ip = 10.0.2.38

########################### Installing ################################ 

I did the following on both machines:

 

- I installed MySql-Max (Linux (x86, glibc-2.2, static, gcc) 4.1.7 

http://dev.mysql.com/get/Downloads/MySQL-4.1/mysql-max-4.1.7-pc-linux-i6
86.tar.gz/from/pick

 

- I extracted the tar file into the root folder, and installed the mysql
db by running the mysql_install_db script in the scripts directory.  (In
the mysql directory type-  ./scripts/mysql_install_db)

 

- I then created a config.ini file which I placed in the mysql
directory.  I also created a my.cnf file which I placed in the
mysql/data directory.

################### Config.ini #######################################

 [NDBD DEFAULT]

NoOfReplicas= 2

 

[MYSQLD DEFAULT]

[NDB_MGMD DEFAULT]

[TCP DEFAULT]

 

[NDB_MGMD]

HostName= 10.0.2.39      (10.0.2.38 on machine B)

 

[NDBD]

HostName= 10.0.2.38

DataDir= /root/mysql/data

 

[NDBD]

HostName= 10.0.2.39

DataDir= /root/mysql/data

 

[MYSQLD]

[MYSQLD]

[MYSQLD]

###################### My.cnf ########################## 

The my.cnf file on both machines is:

[mysqld]

ndbcluster

###################### Starting the cluster ############# 

To start the cluster I did the following:

(please note that MySQL is installed in the /root/mysql directory)

 

Machine A:

- opened a terminal.

- typed-   cd mysql

- typed-   ./bin/ndb_mgmd

       - starts the cluster manager

- typed-   ./bin/ndbd --initial

       - please note, only use the '--initial' parameter if it is the

        first time you are starting the node.  

- typed- ./bin/mysqld_safe --user=root &

       - starts mysql.  The terminal may stick here so use ctrl-c to get

         a new prompt.

- typed- ./bin/mysql

       - starts the mysql monitor.

- typed-  use test;

       - to use the test database.

 

Machine B:

- follow the same steps as Machine A:

###################### Testing the cluster ############# 

On Machine A:

- at the mysql monitor prompt

- type-  use test;

      - to use the test database.

- type-  create table cluster_test (i int) engine=ndbcluster;

      - this should create a clustered table called cluster_test.

 

On Machine B:

- at the mysql monitor prompt

- type-  use test;

- type-  show tables;

      -  this should show the cluster_test table created on Machine A.

 

Inserting

Subsequent inserts etc. can be done at the mysql monitor prompt.

Example:

On Machine A:

-        type- insert into cluster_test values(314159);

 

On Machine B:

-        type- select * from cluster_test;

    - should display the value 314159.

##########################################################
Categories
php

使用Pear::Pager类的一个问题

今天把公司的服务器从php4升级到php5,问题来了.最严重的是使用Pear::Pager类,报错如下:
Fatal error: Cannot re-assign $this in D:xampphtdocstmptest.php on line 5

看了下Pager类的构造,有如下代码:
$this = ……………..;

看来从php5开始不再支持这种对自身重新实例化的写法了,只好重写了Pager类草草收场

[@more@]

Categories
php

php代码美化程序PHP_Beautifier试用手记

在pear的rss列表上看到了PHP_Beautifier 0.1.1 beta发布,便下载回来试用:
>>pear install PHP_Beautifier
………………………………………..

顺利完成,看了下帮助,还带有命令行工具,方便:

D:xamppphp>php_beautifier –help

Usage: php_beautifier [options]
and/or can be ‘-‘, which means stdin/stdout.
you can use ? and * for batch processing
can be a dir (ending with ‘/’ or a real dir)
or a file (without ‘/’)
multiple ins and one out = merge all files in one output
Options:
–input or -f input file – default: stdin
–output or -o output dir or file – default: stdout
–indent_tabs or -t indent with tabs
–indent_spaces or -s indent with spaces – default
–filters or -l Add filter(s)
–directory_filters or -d Include dirs for filters
–compress or -c Compress output
–recursive or -r Search in subdir recursively
–help or -? display help/usage (this message)

Filter definition:
–filters "Filter1(setting1=value1,setting2=’value2′) Filter2()"

不过试用下来,处理的不是太完美,比如复杂点php代码美化后不整齐之类的,期待更好的版本出现 [@more@]

Categories
php

让editplus的Function list显示php5的函数

如果你开始使用php5了,而且正好又是editplus的忠实用户,一定会为editplus的function列表无法正确显示而烦恼.这时候,我们不能怨社会,php5新增的public,private,proctectd,static关键字才是罪恶的根源,function不再是function,而是public function….

当然,这一切不会难倒我们,editplus具有很好的可定制性,以下步骤可以轻松解决这个问题:

  • 打开tools->perferences->Files->Setting&syntax
  • 选择File types->PHP
  • 修改Function pattern
    ^[ t]*function[ t].*([^;]*$ 变成 ^[ t]*(function |public |protected |private |static).*([^;]*$
  • 点ok保存设置

好了,按下ctrl+F11,看看函数窗口,有没有显示出所有的函数呢?

[@more@]

Categories
common

在apache上给一个虚拟主机同时绑定两个端口

今天给同一虚拟主机添加了两个端口,过程如下:[@more@]

今天给同一虚拟主机添加了两个端口,过程如下:

绑定端口为:80,8080

1.在httpd.conf中添加:

Listen 8080

2.复制原虚拟主机配置

 

以下是代码片段:

<VirtualHost *:80>

…..

</VirtualHost>

添加:

 

以下是代码片段:

<VirtualHost *:8080>

…..

</VirtualHost>

但是实际上有更简化的写法:

以下是代码片段:

<VirtualHost *:80 *:8080>

…..

</VirtualHost>

 

重启apache观察配置是否生效

Categories
common

定制apache目录列表的描述

Apache中目录的Option设置为Indexes后,文件和文件夹将列表出来,其中有一项是‘描述’
Description的,这个属性可以对文件进行一些描述,但是如何赋值呢?