我有一个cron作业,它的输出现在重定向到一个文件.它看起来如下
0 9 * * * /bin/sh /bin/cleanup.sh > /home/darkknight/cleanup.log
任何人都可以帮我重新输出到stdout吗?
我有一些java代码:
class Protected{
int n = 1;
public Protected(){
System.out.println("Constructor of protected");
System.out.println("========================");
System.out.println("n = "+n);
System.out.println();
}
}
class Derived extends Protected{
Derived(){
System.out.println("Constructor of derived");
System.out.println("======================");
System.out.println("n = "+(n+1));
}
}
public class Demo{
public static void main(String args[]){
Derived ob2 = new Derived();
}
}
Run Code Online (Sandbox Code Playgroud)
我得到的输出为:
constructor of protected
========================
n=1
constructor of Derived
========================
n=2
Run Code Online (Sandbox Code Playgroud)
这就是我要的:
constructor of Derived
========================
n=2
Run Code Online (Sandbox Code Playgroud) 我刚开始学习Perl.当我移动到面向对象时,我得到一个错误
Can't locate object method "say_hello" via package "1" (perhaps you forgot to load "1"?) at ./main.pl line 8.
Run Code Online (Sandbox Code Playgroud)
我搜索了很多解决方案.有像一些类似的问题,这.我的理解是它不是一般问题.
这是我的课
# MyModule.pm
package MyModule;
use strict;
use warnings;
sub new {
print "calling constructor\n";
}
sub say_hello {
print "Hello from MyModule\n";
}
1;
Run Code Online (Sandbox Code Playgroud)
这是我的测试脚本
# main.pl
#!/usr/bin/perl -w
use strict;
use warnings;
use MyModule;
my $myObj = new MyModule();
$myObj->say_hello();
Run Code Online (Sandbox Code Playgroud)
如果删除最后一行,代码工作正常 main.pl