英文:
Perl: Issue coming while running script via task scheduler (Windows) and not via command line
问题
my $jobs=`bjobs -w | tr -s " " | cut -d " " -f7 | tail -n +2 | sort -u | grep -i "_PV_"`; ## 找出在cmd上运行的所有作业
print "$jobs is jobs\n";
my @jobsArray = split("\n", $jobs);
英文:
Below is the code which I am using (in windows(administrator mode)):
my $jobs=`bjobs -w | tr -s " " | cut -d " " -f7 | tail -n +2 | sort -u | grep -i "_PV_"`; ## Find out all the jobs running on cmd
print "$jobs is jobs\n";
my @jobsArray = split("\n", $jobs);
When running via command line, no issue is coming .(##cygwin is installed on my system)
But, when scheduling the task via task scheduler and running, below issue is coming:
-uThe system cannot find the file specified.
tail: write error
is jobs
How to get rid of this error?
答案1
得分: 0
通过在任务计划程序的“启动位置”选项中添加有效路径(无权限问题),问题得以解决。
在任务计划程序的“启动位置”中没有路径时,由于脚本正在以管理员模式运行,cmd 中的默认路径将变为“C:\Windows\System32”
,这可能导致一些权限问题。通过在任务计划程序的任务中添加“启动位置”路径,问题得以解决,因为它改变了在默认管理员 cmd 中打开的目录,使其成为有效的(无权限错误的)路径,例如,cd “C:\\Users”
。
英文:
Problem solved by adding a valid path (with no permission issue) in "start in" option of task scheduler
With no path in "start in" of task scheduler, as script was running in administrator mode, default path in cmd would be coming "C:\Windows\System32"
which might be having some permission issue. Adding "start in" path in task of task scheduler solved the problem as it changed the directory, which opens up in a default admin cmd, to a valid (permission error free) path (like, cd "C:\\Users"
).
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论