简体   繁体   中英

Redirecting output of system calls with perl in an initramfs

I've got this perl script that runs with the initramfs. I've come across a bunch of little problems I don't understand that are surely related to the shell. The particular one I'm asking about is this:

system("/sbin/e2fsck -f $dev");

system("/sbin/e2fsck -f $dev >/dev/null");

The one redirecting to /dev/null fails. Ultimately, I want to be grabbing the output:

open IN, "/sbin/e2fsck -f $dev |";

But this fails too.

Here's the answer: e2fsck needs a terminal for interactive repair. Passing the -y flag fixed that. Thanks.

Is it because your /bin/sh is really /bin/dash ? Cf this discussion on bad-fd-number and this fix which has some suggestions for using a syntax compatible with dash .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM