最新发表

SecureCRT rz 上传rar,gif文件不正确及上传大容量文件失败问题解决

linux 与 windows 文件传输:rz/sz
ZModem is a full-duplex file transfer protocol that supports fast data transfer rates and effective error detection. ZModem is very user friendly, allowing either the sending or receiving party to initiate a file transfer. ZModem supports multiple file (”batch”) transfers, and allows the use of wildcards when specifying filenames. ZModem also supports resuming most prior ZModem file transfer attempts.

rz,sz是便是Linux/Unix同Windows进行ZModem文件传输的命令行工具

windows端需要支持ZModem的telnet/ssh客户端(比如SecureCRT)

运行命令rz,即是接收文件,SecureCRT就会弹出文件选择对话框,选好文件之后关闭对话框,文件就会上传到当前目录

注意:单独用rz会有两个问题:上传中断、上传文件变化(md5不同),解决办法是上传是用rz -be,并且去掉弹出的对话框中“Upload files as ASCII”前的勾选。

-a, –ascii
-b, –binary 用binary的方式上传下载,不解释字符为ascii
-e, –escape
强制escape 所有控制字符,比如Ctrl+x,DEL等

rar,gif等文件文件采用 -b 用binary的方式上传。

文件比较大而上传出错的话,采用参数 -e

如果用不带参数的rz命令上传大文件时,常常上传一半就断掉了,很可能是rz以为上传的流中包含某些特殊控制字符,造成rz提前退出。

一次怪异的Ucenter头像无法上传问题

LAMP系统

Discuz    access denied for agent changed 错误

为了解决中文路径以及中文文件名下载问题,安装了mod_encoding模块
过了一段时间后才发现ucenter上传头像图片出现莫名的access denied for agent changed错误,查遍了所有的官方以及非官方的资料,都没有找到正确的解决方法。
咨询官方技术人员,给后台权限他们查看配置等,无果。

后来在网上发现有同样的问题。说是安装了mod_encoding后出现的问题。想起也曾经安装过这个模块。赶紧注释掉,发现一切都ok了。
最终发现,将mod_encoding取消后,所有症状消失。想其原因有可能是该模块将url编码转换,导致ucenter无法获取到正确的user- agent值,出现错误。。。不过疑问是,,为什么这个问题属于间歇性问题,也就是说,有时候出现,有时候不出现。。
目前办法:取消该模块的使用

ls 文件按时间排序

ls -lrt   最新的在最后面。
ls -lt 显示最近被修改文件的长列表,较旧的文件跟在后面。

SecureCRT标签跟随设置(转载)

linux主机上

在/etc/sysconfig/bash-prompt-default
加入:

echo -ne “\e]2;${USER}@${HOSTNAME}\a”

PS:/etc/sysconfig/bash-prompt-default要有可执行权限

问题提出:
作为系统管理员
经常需要在模拟终端上远程登上服务器做各种操作
而且很多时候需要同时用不同的窗口登上不同的服务器
当登上服务器太多的时候
就偶然会发现突然不知道哪个窗口登的是哪台服务器了
这可是个大问题
如果在错误的服务器里执行了特定命令
有时候后果是非常严重的
因而就想能否有种办法能让人一目了然的分辨出哪个窗口登陆的是哪台机器
因为我们分辨机器大多是靠ip地址
就想能否在窗口的标题部分显示机器的ip就最好了

技术实现:
bash支持环境变量PROMPT_COMMAND
将其设置为一个命令行字符串或者是包含命令行字符串的一个文件的文件名
命令行用来在显示prompt之前执行
而xterm又支持3种escape序列
可以用来更改xterm的“icon name”和”title”两者之其一或两者都改
还有
在redhat系列的机器上(redhat、fedora)
都支持文件/etc/sysconfig/bash-prompt-xterm来保存bash+xterm下的PROMPT_COMMAND环境变量的内容
结合这几点
我们就可以轻松实现“在窗口标题部分显示已登陆服务器的ip地址”这个功能
我当前用的是

echo -ne “\e]2;$(ifconfig | awk ‘/inet addr:/ && ! /inet addr:127\./ { sub (”addr:”, “”); print $2 }’ | sed -e :a -e ‘$!N;s/\n/\|/g;ta’):${PWD}\a”

这里的”\e]2″是xterm支持的第三种escape序列,用来设置窗口的标题
“$(.*)”的内容是shell命令,用来取出服务器的当前ip地址(除去127.x.x.x)列表,并用”|”连接起来
“${PWD}”是指当前的工作目录
“\a”是xterm支持的escape序列的结束符

引申一下:
后来发现,所谓”xterm支持的3种escape序列”,基本上其他的term都支持
起码secure CRT里所带的term类型都支持(我测过)
而且redhat系列的服务器(redhat, fedora)除了支持/etc/sysconfig/bash-prompt-xterm外
还支持/etc/sysconfig/bash-prompt-screen、/etc/sysconfig/bash-prompt-default
用来存储当term类型是screen时和term类型不是xterm和screen时的PROMPT_COMMAND环境变量的值
于是乎

cp /etc/sysconfig/bash-prompt-xterm /etc/sysconfig/bash-prompt-default
cp /etc/sysconfig/bash-prompt-xterm /etc/sysconfig/bash-prompt-screen

这样的话
不管secure crt里term设成什么
都能在其标题里显示服务器ip

补充一下:
为什么这里还有个term被设成screen的case呢
那是因为我们常用的命令screen
执行的时候会将环境变量PROMPT_COMMAND设成”screen”

隐藏shell光标

隐藏shell光标的主要方法是产生有效的转义系列,方法如下:

echo ^[[?25l

请注意这个转义系列的敲法是,<ctrl+v><escape>[?25l(是字母l不是数字1)

先同是按下<ctrl> 和 v ,松开后然后按<escape>,就会出现^[ ,再输入[?25l

要使光标恢复则

echo ^[[?25h
注:这些字符一定要手敲,不要粘贴!

shell命令的常用快捷键(转)

下面是一些shell的常用快捷键,快捷键玩熟悉了在一定程度上是可以提高工作效率滴…
Ctrl + a 切换到命令行开始
Ctrl + e 切换到命令行末尾
Ctrl + l 清除屏幕内容
Ctrl + u 清除光标之前的内容
Ctrl + k 清除光标之后的内容
Ctrl + h 类似于退格键
Ctrl + r 在历史命令中查找 (这个非常好用,输入关键字就调出以前的命令了)
Ctrl + c 终止命令
Ctrl + d 退出shell
Ctrl + z 转入后台运行..
alt键比较少用,因为很多地方与远程登陆工具是有冲突的..
Alt + f 切换光标前的字母
Alt + b 切换光标后的字母

Apache支持perl在web的应用

apache支持perl在web的应用

1、安装apache
如apache安装在/usr/local/apache2/
2、安装perl
perl默认在linux系统里是自带的,

PS:要注意安装版本的差异,版本过低会报错
Can’t locate Apache/Response.pm in @INC …

Found this issue in Aurora SPARC Linux 2.0 (Fedora Core 3 for SPARC) when trying to install… turns out that after installing all the modules for rt, I still had an ancient verion of CGI.pm, which was not intended to correctly detect the mod_perl2 modules vs. regular mod_perl. Upgrading CGI via CPAN quickly resolved this problem after an embarrassing number of hours troubleshooting.

If Apache refuses to start after you add PerlRequire bin/webmux.pl to your config and you’re sure you’ve got a valid mod_perl2 installation, try upgrading CGI to the latest version.

3、安装mod_perl
如我现在版本

tar zxvf mod_perl-2.0-current.tar.gz
cd mod_perl-2.0.4
perl Makefile.PL
make
make test
make install

PS:如果apache在运行帐号的权限是nobody的话,而mod_perl-2.0.4是在root在目录下,在make test的过程将会报错
You are running the test suite under user ‘root’.
Apache cannot spawn child processes as ‘root’, therefore
we attempt to run the test suite with user ‘nobody’ (99:99).
The problem is that the path (including all parent directories):
/root/mod_perl-2.0.4/t
must be ‘rwx’ by user ‘nobody’, so Apache can read and write under that
path.

建议将mod_perl-2.0.4 放在/tmp目录下

安装后将会在/usr/local/apache2/modules/有一个mod_perl.so
ls /usr/local/apache2/modules/mod_perl.so

4、配置http.conf
在http.conf里
a、载入模块
LoadModule perl_module modules/mod_perl.so
b、<IfModule mime_module>里加入后缀解析
AddHandler cgi-script .cgi .pl

c、vhost设置里加入执行

<VirtualHost *:80>
ServerName www.588k.com
DocumentRoot /opt/wwwroot/www.588k.com
ScriptAlias /perl/ “/opt/wwwroot/www.588k.com/perl/”               ##/opt/wwwroot/www.588k.com/perl为网站的documentroot的perl目录

<Location /perl>
SetHandler perl-script
PerlHandler ModPerl::Registry
Options +ExecCGI
allow from all
PerlSendHeader On
</Location>

</VirtualHost>

5、测试
先重启apache
在documentroot下建立test.pl 内容如下

#!/usr/bin/perl -w
use CGI;
{
my $q = new CGI;
print $q->header(),
$q->start_html(“hello perl world!”),
$q->h1(‘hello perl world, by sakia’),
$q->end_html();
}

通过http://www.588k.com/perl/test.pl如果能够正常输出
hello perl world, by sakia

配置成功

VMware conversion error: Error: Unable to obtain the IP address of the target virtual machine running the Converter helper server.

While running VMware converter, one may encounter this error;

Error: Unable to obtain the IP address of the target virtual machine running the Converter helper server.

For those who may not know how to fix it, it’s really easy (and I feel a little ashamed that I have to post the solution here, but who knows, someone may need the help, so step forward my young Padawan, and pay attention)…

The helper virtual machine must be able to establish an SSH connection with the source computer. By default the helper virtual machine gets its IP address assigned by DHCP. If there is no DHCP server available on the network chosen for the target virtual machine you must manually assign it an IP address.

大致翻译:Converter转化机必须能ssh连接源机器。默认情况下Converter转化机通过DHCP来获取目标虚拟机的IP地址,如果网络内没有DHCP服务器对目标虚拟机分配IP,那必须手工来设定目标虚拟机的IP地址
所以如果没有对目标虚拟机设置一个ip的话,将会出现上述的报错

利用sendmail发送附件

sendmail发附件需要用uuencode命令这个命令在sharutils组件中,可以远程安装

apt-get install sharutils
yum install sharutils

也可以用rpm安装,可以去安装光盘里找。如我的redhat 5.2 x_86_64系统,rpm包:sharutils-4.6.1-2.x86_64.rpm
安装后有uuencode命令

开启sendmail服务
#/etc/rc.d/init.d/sendmail start

现在就可以发送附件了
uuencode /root/tmp.tar tmp.tar | mail -s “tmp.tar” xxx@email.com

注:如上发送时如果加上邮件内容
uuencode /root/tmp.tar tmp.tar | mail -s “tmp.tar” xxx@email.com < >test….
>EOF
如此发送的话,邮件内容将会覆盖掉附件。

shmmax的含义与设置小结

shmmax内核参数定义单个共享内存段的最大值,即单个进程的最大内存使用量,如果该参数设置小于某些进程的设置,那么就会被分配多个共享内存段。这在繁忙的系统中可能成为性能负担,带来系统问题。32位CPU的寻址空间是4G,32位机器shmmax一般不能超过4G

老版本CentOS、Redhat的shmmax默认值为33554432字节(33554432bytes/1024/1024=32MB)。现在新版本是
[root@localhost ~]# cat /proc/sys/kernel/shmmax
4294967295

长久修改shmmax的值:
vi /etc/sysctl.conf 编辑这个文件,在最后一行加入
kernel shmmax = 807374182
然后执行以下命令使配置生效:
/sbin/sysctl -p

临时更改该值:
echo 字节数 > /proc/sys/kernel/shmmax

按照以上方法更改,在每次重启系统时,该值会被自动还原。如果想永久更改,可以修改/etc/sysctl.conf文件,设置:
kernel.shmmax = 字节数

注:vi /etc/sysctl.conf 编辑这个文件,在最后一行加入
kernel shmmax = 807374182
重启生效.