我设置了一个在我的帐户下运行的计划任务.它运行的所有内容,即使成功,也会返回(2)的操作代码.我在下面的链接中看了这个错误代码,并声称它找不到特定的文件.
http://www.hiteksoftware.com/knowledge/articles/049.htm
即使我做一些非常简单的事情,我也会找回(2)的操作代码.例如:
run program: cmd.exe
start in path: c:\windows\system32
Run Code Online (Sandbox Code Playgroud)
我启动任务,我看到进程在我的任务管理器中运行,所以我终止了任务.然后我检查计划任务的历史记录,它显示为(2).
对我正在做的事情更加现实:
<?
/* file in c:\php\test.php */
echo "hello";
?>
Run Code Online (Sandbox Code Playgroud)
运行程序: php.exe
从路径开始: c:\php
参数: -f test.php
一切都在命令行中工作,但Windows计划任务保持返回操作代码(2).我应该看到(0)的操作代码,这意味着成功,正确吗?
我正在尝试实现Node.JS apn模块以连接到APNS(Apple推送通知服务),以便从运行Ubuntu 12.04的Amazon EC2实例上托管的节点服务器(使用ExpressJS)向iPhone设备发送通知.我收到此错误:
"Error: Cannot switch to old mode now.",
" at emitDataEvents (_stream_readable.js:720:11)",
" at ReadStream.Readable.resume (_stream_readable.js:705:3)",
" at TLSSocket.<anonymous> (/home/ubuntu/usemebeta/routes/message.js:101:48)",
" at TLSSocket.g (events.js:186:14)",
" at TLSSocket.EventEmitter.emit (events.js:97:17)",
" at TLSSocket.<anonymous> (_tls_wrap.js:579:16)",
" at TLSSocket.EventEmitter.emit (events.js:97:17)",
" at TLSSocket._finishInit (_tls_wrap.js:198:8)"
Run Code Online (Sandbox Code Playgroud)
当我调用apn模块函数来推送通知时.但是,当我在文件中写入的函数中执行相同的操作并执行该文件时,它的工作正常.请帮忙.我该如何解决这个问题呢?
为什么GetType().Name在字符串数组上进行调用Object[]而不是String[]?这似乎发生在任何元素类型中,例如Import-Csv会给你一个Object[]但每个元素都是一个PSCustomObject.
这是一个带数组的例子 String
$x = @('a','b','c')
$x[0].GetType().Name #String
$x.GetType().Name #Object[]
Run Code Online (Sandbox Code Playgroud) 我想在不使用root的情况下在mac os x上启动.sh类型或.py文件,我在google搜索并发现launchctl可以帮助我,
所以我读教程并在教程中做同样但它不适合我,[我使用mac os x 10.9 x64]
我的.plist文件[每隔60秒运行1.sh文件]:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.alvin.crontabtest</string>
<key>ProgramArguments</key>
<array>
<string>/Users/paul/Desktop/1.sh</string>
</array>
<key>Nice</key>
<integer>1</integer>
<key>StartInterval</key>
<integer>60</integer>
<key>RunAtLoad</key>
<true/>
<key>StandardErrorPath</key>
<string>/tmp/AlTest1.err</string>
<key>StandardOutPath</key>
<string>/tmp/AlTest1.out</string>
</dict>
</plist>
Run Code Online (Sandbox Code Playgroud)
1.sh的来源:
echo '+' >> /Users/paul/Desktop/worked.txt
Run Code Online (Sandbox Code Playgroud)
我将Run.plist放在/Users/paul/Run.plist中
并从终端运行命令:
launchctl load /Users/paul/Run.plist
Launchctl start com.alvin.crontabtest
Run Code Online (Sandbox Code Playgroud)
命令执行没有任何错误,但我没有看到working.txt中的任何内容
有人可以帮我吗?
显然,在PowerShell(第3版)中并非所有$null都是相同的:
>function emptyArray() { @() }
>$l_t = @() ; $l_t.Count
0
>$l_t1 = @(); $l_t1 -eq $null; $l_t1.count; $l_t1.gettype()
0
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Object[] System.Array
>$l_t += $l_t1; $l_t.Count
0
>$l_t += emptyArray; $l_t.Count
0
>$l_t2 = emptyArray; $l_t2 -eq $null; $l_t2.Count; $l_t2.gettype()
True
0
You cannot call a method on a null-valued expression.
At line:1 char:38
+ $l_t2 = emptyArray; $l_t2 -eq $null; $l_t2.Count; $l_t2.gettype()
+ ~~~~~~~~~~~~~~~
+ CategoryInfo …Run Code Online (Sandbox Code Playgroud) 我有一条路径,让我们说C:\temp\something.js,我想在Windows上获得路径的大小写确切版本 - 所以如果C:\Temp\someThing.js存储在磁盘上,我想得到这个值(路径).
如何从Node.js中的后一个路径获取前一个路径?
我已经通过FS API(去https://nodejs.org/api/fs.html),我还没有发现任何有用的东西(即fs.realpathSync,fs.statSync,fs.accessSync没有回我的需要).
如果它结束,我需要修剪路径\.
C:\Ravi\
Run Code Online (Sandbox Code Playgroud)
我需要换到
C:\Ravi
Run Code Online (Sandbox Code Playgroud)
我有一个路径不会结束的情况\(然后它必须跳过).
我尝试过.EndsWith("\"),但是当我有\\而不是时,它失败了\.
这可以在PowerShell中完成,而无需诉诸条件吗?
所以我从文件名中删除特殊字符并用空格替换。除了其中包含单反斜杠的文件之外,我所有的工作都已完成。请注意,这些文件是在 OS X 上的 Finder 中创建的
old_name="testing\this\folder"
new_name=$(echo $old_name | tr '<>:\\#%|?*' ' ');
Run Code Online (Sandbox Code Playgroud)
这导致 new_name 被“测试 hisolder” 我怎样才能删除反斜杠而不是前面的字符?
我在这样的bash脚本中提示问题:
optionsAudits=("Yep" "Nope")
echo "Include audits?"
select opt in "${optionsAudits[@]}"; do
case $REPLY in
1) includeAudits=true; break ;;
2) includeAudits=false; break ;;
"\n") echo "You pressed enter"; break ;; # <--- doesn't work
*) echo "What's that?"; exit;;
esac
done
Run Code Online (Sandbox Code Playgroud)
按Enter键时如何选择默认选项?该"\n"案件不赶回车键.
我正在做一些测试,偶然发现了以下情况:
您可以根据需要重载PoShv5中的方法.如果调用不带参数的方法,它可以在内部使用参数调用方法,以保持代码不冗余.我预计这对于构造函数也是如此.
在此示例中,最后一个构造函数按预期工作.其他构造函数仅返回没有设置值的对象.
Class car {
[string]$make
[string]$model
[int]$Speed
[int]$Year
speedUp (){
$this.speedUp(5)
}
speedUp ([int]$velocity){
$this.speed += $velocity
}
# Constructor
car () {
[car]::new('mall', $Null, $null)
}
car ([string]$make, [string]$model) {
[car]::new($make, $model, 2017)
}
car ([string]$make, [string]$model, [int]$Year) {
$this.make = $make
$this.model = $model
$this.Year = $year
}
}
[car]::new() # returns "empty" car
[car]::new('Make', 'Nice model') # returns also an "empty" one
[car]::new( 'make', 'nice model', 2017) # returns a "filled" instance
Run Code Online (Sandbox Code Playgroud)
有没有办法来解决这个问题?我错过了什么?
powershell constructor overloading class constructor-chaining
powershell ×4
bash ×3
macos ×3
node.js ×2
arrays ×1
class ×1
coercion ×1
collections ×1
constructor ×1
cron ×1
ends-with ×1
filepath ×1
interactive ×1
javascript ×1
launchd ×1
null ×1
overloading ×1
path ×1
startup ×1
stream ×1
text-parsing ×1
tr ×1
types ×1
user-input ×1
windows ×1
windows-7 ×1