在启动脚本linux中运行lap-request

时间:2014-10-30 22:37:01

标签: linux perl shell

我在Linx上启动了一个启动脚本:

的/ etc / INIT / selfconfig

#! /bin/sh  
# /etc/init.d/selfconfig

USER=root
HOME=/root

export USER HOME

/usr/bin/perl /boot/coder_settings/saconfig.pl

exit 0

此脚本运行perl脚本

/boot/coder_settings/saconfig.pl

#! /usr/bin/perl

lwp-request -m GET http://192.168.1.16:3000/hostname > /boot/coder_settings/hostname.txt

但是我收到了这个错误:

Search pattern not terminated at /boot/coder_settings/saconfig.pl line 3.

我做错了什么?

1 个答案:

答案 0 :(得分:1)

虽然lwp-request是perl脚本,但它的设置是作为命令行程序运行。

您只需更改bash脚本;

#! /bin/sh 
....
/usr/bin/perl /boot/coder_settings/saconfig.pl

要;

#! /bin/sh 
....
lwp-request -m GET http://192.168.1.16:3000/hostname > /boot/coder_settings/hostname.txt

如果要从perl运行lwp-request作为shell命令,请使用反引号将perl脚本更改为;

#! /usr/bin/perl

`lwp-request -m GET http://192.168.1.16:3000/hostname > /boot/coder_settings/hostname.txt`
相关问题