为什么是“ - ”在脚本名称中导致问题? [英] Why is "-" in a script name causing problems?

查看:47
本文介绍了为什么是“ - ”在脚本名称中导致问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题在于:


我写了一个名为test.cgi的脚本(不是我们都是吗?)。一旦它做了我想要的东西,保存副本并创建一个名为test-2.cgi的新版本。然后我的问题开始了...


使用这个新脚本,路径现在将包含脚本的名称......


例如:


运行test.cgi时:

/usr/www/users/me/cgi-bin/new_script/test.cgi


$ path / file.name>> /usr/www/users/me/cgi-bin/new_script/file.name


哪个是正确的!


运行test- 2.cgi:

/usr/www/users/me/cgi-bin/new_script/test-2.cgi


我会得到:


$ path / file.name>> /usr/www/users/me/cgi-bin/new_script/test-2.cgi/file.name


插入程序的名称就好像它是一个目录。毋庸置疑,任何事情都不再奏效。


我花了一段时间才意识到这一点,因为我不知道如何纠正它,我只是简单地使用完整的路径然后使用$ path变量。这让事情变得更糟。该脚本现在正在noname下创建文件。用户,否认我有权更改写入他们的权限...


我失去了6个小时试图弄清楚为什么我的脚本停止工作。我上午3点睡觉时完全沮丧。我是Perl的新手,对Unix有些陌生......

最后一个解决方案

今天早上我删除了 - "超出名称(test2.cgi),一切正常!我觉得真的很蠢:-(


你能解释一下为什么 - 会像这样搞砸了大时间吗?


我们必须在脚本名称中避免使用其他字符,以防止像我这样的简单家伙使用电脑进行目标练习吗?


非常感谢,


Yves

解决方案

path / file.name>> / usr / www / users / me / cgi-bin / new_script / file.name


哪个是正确的!


运行test-2.cgi时:

/ usr / www / users / me / cgi-bin / new_script / test-2.cgi


我会得到:


< blockquote> path / file.name>> /usr/www/users/me/cgi-bin/new_script/test-2.cgi/file.name


程序的名称就像它是一个目录一样插入自己。不用说没有什么工作了。


我花了一段时间才意识到这一点我不知道如何纠正它,我只是使用完整路径而不是使用


路径变量。这让事情变得更糟。该脚本现在正在noname下创建文件。用户,否认我有权更改写入他们的权限...


我失去了6个小时试图弄清楚为什么我的脚本停止工作。我上午3点睡觉时完全沮丧。我是Perl的新手,对Unix有些陌生......

最后一个解决方案

今天早上我删除了 - "超出名称(test2.cgi),一切正常!我觉得真的很蠢:-(


你能解释一下为什么 - 会像这样搞砸了大时间吗?


我们必须在脚本名称中避免使用其他字符,以防止像我这样的简单家伙使用电脑进行目标练习吗?


非常感谢,


Yves


Here is the problem:

I wrote a script called test.cgi (don''t we all?). Once it was doing what I want a save a copy and created a new version called test-2.cgi. Then my problems started...

With this new script, the path would now include the script''s name...

Ex:

When running test.cgi:
/usr/www/users/me/cgi-bin/new_script/test.cgi

$path/file.name >> /usr/www/users/me/cgi-bin/new_script/file.name

Which is correct!

When running test-2.cgi:
/usr/www/users/me/cgi-bin/new_script/test-2.cgi

I would get:

$path/file.name >> /usr/www/users/me/cgi-bin/new_script/test-2.cgi/file.name

The name of the program inserted itself like if it was a directory. Needless to say that nothing was working any longer.

It took me a while to realise that and since I didn''t know how to correct it, I simply use the full path rather then using the $path variable. That made matter worse. The script was now creating files under "noname" user, denying me the right to change permission to write into them...

I lost 6 hours trying to figure out why my script stops working. I went to bed a 3 AM totally frustrated. I''m new to Perl and somewhat a stranger to Unix...

AT LAST A SOLUTION
This morning I removed the "-" out of the name (test2.cgi) and everything was working fine!!! I felt really stupid :-(

Can you explain to me why would a "-" screw up BIG time like this?

Is there other character we must avoid in script name, to prevent a simple guy like me to use is computer for target practice???

Thanks a lot all,

Yves

解决方案

path/file.name >> /usr/www/users/me/cgi-bin/new_script/file.name

Which is correct!

When running test-2.cgi:
/usr/www/users/me/cgi-bin/new_script/test-2.cgi

I would get:


path/file.name >> /usr/www/users/me/cgi-bin/new_script/test-2.cgi/file.name

The name of the program inserted itself like if it was a directory. Needless to say that nothing was working any longer.

It took me a while to realise that and since I didn''t know how to correct it, I simply use the full path rather then using the


path variable. That made matter worse. The script was now creating files under "noname" user, denying me the right to change permission to write into them...

I lost 6 hours trying to figure out why my script stops working. I went to bed a 3 AM totally frustrated. I''m new to Perl and somewhat a stranger to Unix...

AT LAST A SOLUTION
This morning I removed the "-" out of the name (test2.cgi) and everything was working fine!!! I felt really stupid :-(

Can you explain to me why would a "-" screw up BIG time like this?

Is there other character we must avoid in script name, to prevent a simple guy like me to use is computer for target practice???

Thanks a lot all,

Yves


这篇关于为什么是“ - ”在脚本名称中导致问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆