通过Cygwin上的套接字运行Python脚本时,我不断收到以下错误:
Traceback (most recent call last):
File "M:/view/cmtest_ccProxy/bce/cmTools/lib/CC.py", line 321, in standAlone
results = Process.execute (cmd = cmd, opts = opts)
File "M:/view/cmtest_ccProxy/bce/cmTools/lib/Process.py", line 327, in execute
timeout = timeout)
File "/usr/local/lib/python3.4/subprocess.py", line 535, in call
with Popen(*popenargs, **kwargs) as p:
File "/usr/local/lib/python3.4/subprocess.py", line 848, in __init__
restore_signals, start_new_session)
File "/usr/local/lib/python3.4/subprocess.py", line 1382, in _execute_child
restore_signals, start_new_session, preexec_fn)
BlockingIOError: [Errno 11] Resource temporarily unavailable
Run Code Online (Sandbox Code Playgroud)
设置是:服务器端:Cygwin + inetd +为cygwin构建的python客户端:telnet服务器
python脚本运行带有大输出的命令。
import subprocess, os, tempfile, re
def execute (cmd = None,
opts …Run Code Online (Sandbox Code Playgroud) 在一些现有的教程之后,我创建了下面的perl脚本来从xsd生成XML.
脚本:
#!/opt/perl/bin/perl -w
use warnings;
use strict;
use XML::Compile::Schema;
use XML::LibXML::Reader;
use XML::Compile::Util qw/pack_type/;
my $in_qfn = $ARGV[0];
my $out_qfn = $ARGV[1];
open (OUT, ">$out_qfn") || die "Unable to create output file: $out_qfn\n";
# Generate the hash of xml
my $schema = XML::Compile::Schema->new($in_qfn);
my $type = pack_type 'urn:testsample','Document';
my $data = $schema->template('PERL', $type);
$data =~ s/#.*//g;
$data =~ s/\s*//g;
$data = eval($data);
# Print the xml
my $doc = XML::LibXML::Document->new('1.0','UTF-8');
my $write = $schema->compile(WRITER=>$type);
my $xml = $write->($doc,$data);
$doc->setDocumentElement($xml); …Run Code Online (Sandbox Code Playgroud) 用于生成随机字符串的脚本:
sub rand_Strings {
my @chars = ("A".."Z", "a".."z", "0".."9");
my $string;
$string .= $chars[rand @chars] for 1..8;
}
my $strings = &rand_Strings;
print $strings;
Run Code Online (Sandbox Code Playgroud)
但是,它不在子程序中时有效.如果$ string是全局变量,也可以工作.我错过了什么?谢谢,
我有一个由几个单词组成的字符串(由大写字母分隔).
例如:
$string1="TestWater"; # to be splited in an array @string1=("Test","Water")
$string2="TodayIsNiceDay"; # as @string2=("Today","Is","Nice","Day")
$string3="EODIsAlwaysGood"; # as @string3=("EOD","Is","Always","Good")
Run Code Online (Sandbox Code Playgroud)
我知道Perl容易拆分使用split函数作为固定字符,或者匹配正则表达式可以将$ 1,$ 2与固定数量的变量分开.但是如何动态完成呢?提前致谢!
那个帖子Spliting CamelCase没有回答我的问题,我的问题更多地与Perl中的正则表达式相关,那个是在Java中(差异在这里适用).