use IO::Interactive qw(is_interactive); die "hi, no interactive shell allowed here :)\n" if is_interactive(); shift; my $cmd = shift; exec 'sudo', '/run/current-system/sw/bin/systemctl', 'poweroff' if $cmd eq 'poweroff'; die "hi, no valid command given :(\n";