0

My task is to print information for the user who runs this script in the terminal
The information I need to print is the information I get from writing:

parted /dev/... print

Is there any file with the same information so I can open and print it with the perl script,
if not I really have no idea how to get a hold of info about which partition that is "boot"
and the size of each partition

Feels like I've been looking all over the internet, maybe I'm just bad at searching for the
right parameters, but I'm lost and any help is appreciated

1
  • 1
    Please, don't modify a question, ask another one. Commented Jan 24, 2012 at 13:46

2 Answers 2

5

You could run the command and capture the output

open my $cmd, '-|', 'parted', '/dev/...', 'print' || die "Can't run command: $!";

while (<$cmd>) {
    # do something with $_, e.g.
    print;
}

close $cmd || die "Error while closing off command: $!";
Sign up to request clarification or add additional context in comments.

Comments

3

That's what backticks (`) are for:

print `parted /dev/... print`;

print qx(parted /dev/... print);     # Another way to do it

my $output = `parted /dev/... print`;  # Save to variable

...

print $fh $output;   # Use later

See perldoc perlop for more information.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.