GVKun编程网logo

如何在Windows上使用Perl中的空格访问path?(perl空格怎么表示)

22

本文的目的是介绍如何在Windows上使用Perl中的空格访问path?的详细情况,特别关注perl空格怎么表示的相关信息。我们将通过专业的研究、有关数据的分析等多种方式,为您呈现一个全面的了解如何在

本文的目的是介绍如何在Windows上使用Perl中的空格访问path?的详细情况,特别关注perl空格怎么表示的相关信息。我们将通过专业的研究、有关数据的分析等多种方式,为您呈现一个全面的了解如何在Windows上使用Perl中的空格访问path?的机会,同时也不会遗漏关于c – 如何在WIndows上使用Cython编译Pyparsing?、windows-7 – 使用Powershell创建Windows快捷方式,目标路径中的空格问题、windows-7 – 如何在Windows 7上使用Python 3和httplib2调用AWS?、为什么我无法在Windows上使用Python的urlopen()方法?的知识。

本文目录一览:

如何在Windows上使用Perl中的空格访问path?(perl空格怎么表示)

如何在Windows上使用Perl中的空格访问path?(perl空格怎么表示)

我正在将Unix Perl脚本转换为在Windows上运行。 我在path中有空格的问题:

open (IN,"| C:\Program Files\MysqL\MysqL Server 5.1\bin\MysqL.exe -u root -ppwd") or die "$!";

上面的代码会引发以下错误:

''C:Program'' is not recognized as an internal or external command,

我试过包裹在逃脱"这样的:

如何在Perl中以随机顺序打印STDIN中的行?

我怎样才能使batch file像使用Perl一样简单的grep?

为什么Perl的%ENV的空string键值不显示Windowssubprocess?

在Linux上监视目录的程序

限制访问我的网站上的图像,除非通过我自己的htmls

open (IN,"| "C:\Program Files\MysqL\MysqL Server 5.1\bin\MysqL.exe -u root -ppwd"") or die "$!";

但没有喜乐。 我如何处理空间的path?

我正在使用为MSWin32-x86-multithreading构build的ActiveState v5.10.0。

用于创build简单的Microsoft Windows GUI的Perl模块?

mod_perl无法在/ tmp中看到文件

你如何开始在Perl的后台进程?

如何检测打开文件句柄的文件是否在Windows上使用Perl删除?

如何在Perl中为需要JavaScript的页面进行Webtesting?

您正在引用整个命令,包括命令行参数。 你应该把你的第二个逃脱的报价之后的MysqL.exe :

open (IN,"| "C:\Program Files\MysqL\MysqL server 5.1\bin\MysqL.exe" -u root -ppwd") or die "$!";

您可能还对qq()和q()运算符感兴趣,它们允许使用除引号以外的分隔符来分隔字符串。 当你想引用包含引号的字符串时,它们非常有用:

qq[| "C:\Program Files\MysqL\MysqL server 5.1\bin\MysqL.exe" -u root -ppwd]

另外,Perl会很乐意为命令名处理正确的路径分隔符(但并不总是用于命令参数,所以要小心):

qq[| "C:/Program Files/MysqL/MysqL server 5.1/bin/MysqL.exe" -u root -ppwd]

(因为这个例子不需要任何插值,所以可以使用单引号或q()构造:

''| "C:\Program Files\MysqL\MysqL server 5.1\bin\MysqL.exe" -u root -ppwd''

这是Perl,所以有1000种方式(你会看到),单向(逃避空间)

open (IN,"| C:\Program Files\MysqL\MysqL server 5.1\bin\MysqL.exe -u root -ppwd") or die "$!";

你也必须逃离这个空间。

open (IN,"| C:\Program Files\MysqL\MysqL server 5.1\bin\MysqL.exe -u root -ppwd") or die "$!";

或使用旧的8.3名称 :

open (IN,"| C:\Progra~1\MysqL\MysqL~1\bin\MysqL.exe -u root -ppwd") or die "$!";

虽然,我不得不质疑管道MysqL客户端的理智,而不是仅仅使用DBI

我的解决方案是这样做的:

$MysqL = "C:\Program Files\MysqL\MysqL server 5.1\bin\MysqL.exe"; open (IN,"| "$MysqL" -u root -ppwd") or die "$!";

更新:我也注意到@mob正确地指出我把我放在了错误的地方,二十五年的DOS,我错过了:

总结

以上是小编为你收集整理的如何在Windows上使用Perl中的空格访问path?全部内容。

如果觉得小编网站内容还不错,欢迎将小编网站推荐给好友。

c – 如何在WIndows上使用Cython编译Pyparsing?

c – 如何在WIndows上使用Cython编译Pyparsing?

我试图在我的 Windows机器上编译Pyparsing但是遇到以下错误:
python setup.py build_ext --inplace
running build_ext
cythoning pyparsing.pyx to pyparsing.c

Error compiling Cython file:
------------------------------------------------------------
...
       If C{include} is set to true,the matched expression is also parsed (the
skipped text
       and matched expression are returned as a 2-element list).  The C{ignore}
       argument is used to define grammars (typically quoted strings and comment
s) that
       might contain false matches.
    """
    def __init__( self,other,include=False,ignore=None,failOn=None ):
                              ^
------------------------------------------------------------

pyparsing.pyx:2764:31: Expected an identifier,found 'include'

Error compiling Cython file:
------------------------------------------------------------
...
    def __init__( self,failOn=None ):
        super( SkipTo,self ).__init__( other )
        self.ignoreExpr = ignore
        self.mayReturnEmpty = True
        self.mayIndexError = False
        self.includeMatch = include
                           ^
------------------------------------------------------------

pyparsing.pyx:2769:28: Expected an identifier or literal
building 'pyparsing' extension
creating build
creating build\temp.win32-2.7
creating build\temp.win32-2.7\Release
C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W
3 /GS- /DNDEBUG -IC:\Python27\include -IC:\Python27\PC /Tcpyparsing.c /Fobuild\t
emp.win32-2.7\Release\pyparsing.obj
pyparsing.c
pyparsing.c(1) : Fatal error C1189: #error :  Do not use this file,it is the re
sult of a Failed Cython compilation.
error: command '"C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe"' fa
iled with exit status 2

我使用Microsoft Visual C 2008 Express版进行了编译,使用的Pyparsing模块是最新版本.请问,有谁知道如何使这项工作?

解决方法

先生,我按照你的说法做了,但仍然有编译时警告:
    python setup.py build_ext --inplace
    running build_ext
    cythoning pyparsing.pyx to pyparsing.c
    warning: pyparsing.pyx:413:8: Unreachable code
    building 'pyparsing' extension
    creating build
    creating build\temp.win32-2.7
    creating build\temp.win32-2.7\Release
    C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W
    3 /GS- /DNDEBUG -IC:\Python27\include -IC:\Python27\PC /Tcpyparsing.c /Fobuild\t
    emp.win32-2.7\Release\pyparsing.obj
    pyparsing.c
    C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\link.exe /DLL /nologo /INCRE
    MENTAL:NO /LIBPATH:C:\Python27\libs /LIBPATH:C:\Python27\PCbuild /EXPORT:initpyp
    arsing build\temp.win32-2.7\Release\pyparsing.obj /OUT:C:\Users\iProsper\Desktop
    \pyparsing\pyparsing.pyd /IMPLIB:build\temp.win32-2.7\Release\pyparsing.lib /MAN
    IFESTFILE:build\temp.win32-2.7\Release\pyparsing.pyd.manifest
       Creating library build\temp.win32-2.7\Release\pyparsing.lib and object build\
    temp.win32-2.7\Release\pyparsing.exp
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\mt.exe -nologo -manifest build
    \temp.win32-2.7\Release\pyparsing.pyd.manifest -outputresource:C:\Users\iProsper
    \Desktop\pyparsing\pyparsing.pyd;2

警告实际上在第4行:警告:pyparsing.pyx:413:8:无法访问的代码.然后我将该行改为:

    def __getattr__( self,name ):
            if True: #name not in self.__slots__:
                if name in self.__tokdict:
                    if name not in self.__accumNames:
                        return self.__tokdict[name][-1][0]
                    else:
                        return ParseResults([ v[0] for v in self.__tokdict[name] ])
                else:
                    return ""
            else:
                return None

然后重新编译它.我注意到的一件事是,即使我发出警告和编辑,它们都成功编译,但是当我尝试使用以下代码进行测试时:

    from pyparsing import Word,alphas
    greet = Word(alphas) + ',' + Word(alphas) + '!'
    greeting = greet.parseString('Hello,World!')
    print greeting

我收到以下错误:

    Traceback (most recent call last):
      File "C:\nwaomachux\build_pyparsing\checkout.py",line 1,in 
        from pyparsing import Word,alphas
      File "pyparsing.pyx",line 3414,in init pyparsing (pyparsing.c:100064)
    AttributeError: 'builtin_function_or_method' object has no attribute 'ANY_VALUE'

我会进一步修改文件并发送给你检查它,但我只有几个小时的Pyparsing,所以我还没有掌握完整的源代码.

我不知道将withAttribute.ANY_VALUE = object()移动到def withAttribute(args,* attrDict)的开头是什么效果:function表示.请问,它有什么问题?谢谢.

windows-7 – 使用Powershell创建Windows快捷方式,目标路径中的空格问题

windows-7 – 使用Powershell创建Windows快捷方式,目标路径中的空格问题

@H_301_4@ 简短又甜蜜,我在PS中制作快捷方式,只要目标路径中没有空格,快捷方式就可以正常工作.一旦Target中有空格,快捷方式目标就会用双引号括起来,因此不起作用……下面是非工作代码.如果你要删除它会正确的空间(除了它在那一点上没有指向EXE的事实).基本上它不会将目标包装在引号中.

$shell = New-Object -ComObject WScript.Shell
$shortcutX = $shell.CreateShortcut("C:\Short.lnk")
$shortcutX.TargetPath = "C:\apps\application --switch"
$shortcutX.Save()

TL; DR:

作品.

$shortcutX.TargetPath = “C:\apps\application”

不行!

$shortcutX.TargetPath = “C:\apps\application –switch”

为什么?!?!?!?!

解决方法

从 MSDN开始:

This property is for the shortcut’s target path only.

您可以在Argument属性中为快捷方式添加参数.

$shortcutX.Arguments = "-- switch"

在我的盒子(Windows 7 Pro)上,我可以使用具有空格的路径目标来创建快捷方式.

windows-7 – 如何在Windows 7上使用Python 3和httplib2调用AWS?

windows-7 – 如何在Windows 7上使用Python 3和httplib2调用AWS?

我使用httplib2来调用Amazon Web Services(AWS):

http = httplib2.Http(cache='.cache')
response,content = http.request('https://sdb.amazonaws.com/...')

但它没有找到CA(我认为):

File "C:\python32\lib\site-packages\httplib2\__init__.py",line 1059,in request self.disable_ssl_certificate_validation)
File "C:\python32\lib\site-packages\httplib2\__init__.py",line 772,in __init__ context.load_verify_locations(ca_certs)
IOError: [Errno 2] No such file or directory

我的问题:

>我需要做些什么来配置我的操作系统和环境才能使用它?
>我已经看过很多关于确保在Python 2中为SSL构建套接字库的帖子;这适用于Python 3吗?

谢谢!

解决方法

httplib2 / python3文件夹缺少cacerts.txt,因此不会将其复制到Python / lib文件夹中.我手动复制了文件,一切正常.这是httplib2的一个已知问题.

为什么我无法在Windows上使用Python的urlopen()方法?

为什么我无法在Windows上使用Python的urlopen()方法?

为什么这个简单的Python代码不起作用?

import urllib
file = urllib.urlopen('http://www.google.com')
print file.read()

这是我得到的错误:

Traceback (most recent call last):
  File "C:\workspace\GarchUpdate\src\Practice.py",line 26,in <module>
    file = urllib.urlopen('http://www.google.com')
  File "C:\Python26\lib\urllib.py",line 87,in urlopen
    return opener.open(url)
  File "C:\Python26\lib\urllib.py",line 206,in open
    return getattr(self,name)(url)
  File "C:\Python26\lib\urllib.py",line 345,in open_http
    h.endheaders()
  File "C:\Python26\lib\httplib.py",line 892,in endheaders
    self._send_output()
  File "C:\Python26\lib\httplib.py",line 764,in _send_output
    self.send(msg)
  File "C:\Python26\lib\httplib.py",line 723,in send
    self.connect()
  File "C:\Python26\lib\httplib.py",line 704,in connect
    self.timeout)
  File "C:\Python26\lib\socket.py",line 514,in create_connection
    raise error,msg
IOError: [Errno socket error] [Errno 10060] A connection attempt failed because the connected party did not properly respond after a period of time,or established connection failed because connected host has failed to respond

我已经在几个不同的页面上尝试过,但是我永远无法获得urlopen正确执行的方法。

今天的关于如何在Windows上使用Perl中的空格访问path?perl空格怎么表示的分享已经结束,谢谢您的关注,如果想了解更多关于c – 如何在WIndows上使用Cython编译Pyparsing?、windows-7 – 使用Powershell创建Windows快捷方式,目标路径中的空格问题、windows-7 – 如何在Windows 7上使用Python 3和httplib2调用AWS?、为什么我无法在Windows上使用Python的urlopen()方法?的相关知识,请在本站进行查询。

本文标签: