command output

J

jammer

There is no output from this:
`/usr/bin/ls -l "$backupDir/$backupName"`;

This shows correct values:
print "/usr/bin/ls -l $backupDir/$backupName";
 
J

J. Gleixner

jammer said:
There is no output from this:
`/usr/bin/ls -l "$backupDir/$backupName"`;

This shows correct values:
print "/usr/bin/ls -l $backupDir/$backupName";

Correct values??? It prints:

/usr/bin/ls -l /

It sounds like you answered your own question though, whatever
that question was.

Possibly this is what you're after:

perldoc -q "Why can't I get the output of a command with system"
 
G

Gunnar Hjalmarsson

jammer said:
There is no output from this:
`/usr/bin/ls -l "$backupDir/$backupName"`;

Are you sure that the ls program resides in /usr/bin? On my box it's
located in /bin, but in any case

`ls -l "$backupDir/$backupName"`

ought to be sufficient.

Otherwise, if you for some reason don't see what is in STDERR, you may
want to try:

`/usr/bin/ls -l "$backupDir/$backupName" 2>&1`

Please see http://perldoc.perl.org/perlop.html#qx/STRING/
 
P

Paul Lalli

There is no output from this:
                `/usr/bin/ls -l "$backupDir/$backupName"`;

Why would there be? You're capturing the output and then discarding
it by using `` in a void context.

Read perldoc perlop (search for qx//) to learn what `` actually do,
because you don't seem to understand them.

Paul Lalli
 
J

Jürgen Exner

jammer said:
There is no output from this:
`/usr/bin/ls -l "$backupDir/$backupName"`;

Does that surprise you? It shouldn't.
This shows correct values:
print "/usr/bin/ls -l $backupDir/$backupName";

Whatever "correct values" is supposed to mean. It will print that given
string with the two variables $backupDir and $backupName expanded. Did you
expect something else?

Of course backticks to do something different then double quotes. Does that
surprise you?

What is your question/issue/...?

jue
 
T

Tad J McClellan

jammer said:
There is no output from this:
`/usr/bin/ls -l "$backupDir/$backupName"`;


That is because there are no output statements there.

This shows correct values:
print "/usr/bin/ls -l $backupDir/$backupName";


That's nice.

Did you mean to ask a question?
 
M

Mario D'Alessio

jammer said:
There is no output from this:
`/usr/bin/ls -l "$backupDir/$backupName"`;

This shows correct values:
print "/usr/bin/ls -l $backupDir/$backupName";

Assuming you provide the complete lines:

In the first line, you gather data via the backticks, but you
don't do anything with the returned data. It's like having
a line like these:

"blah";
1;

You need to do something with the data; e.g., print it:

print `/usr/bin/ls -l "$backupDir/$backupName"`;

In the second line, you are printing the command itself and
not executing it.

Mario
 
J

jammer

Does that surprise you? It shouldn't.


Whatever "correct values" is supposed to mean. It will print that given
string with the two variables $backupDir and $backupName expanded. Did you
expect something else?

Of course backticks to do something different then double quotes. Does that
surprise you?

What is your question/issue/...?

jue

Printing $backupDir and $backupName show they are not empty.
I wanted to print the output of the ls -l.
I know how to do it now.
 
J

jammer

Printing $backupDir and $backupName show they are not empty.
I wanted to print the output of the ls -l.
I know how to do it now.

I did print `/usr/bin/ls -l "$backupDir/$backupName"`;
It is truncating and printing the last character:
-rw-r--r-- 1 owner group 3858 Mar 14 10:47 /tmp/configs/
file.cog
It should print:
-rw-r--r-- 1 owner group 3858 Mar 14 10:47 /tmp/configs/
file.config
 
J

jammer

I did print `/usr/bin/ls -l "$backupDir/$backupName"`;
It is truncating and printing the last character:
-rw-r--r-- 1 owner group 3858 Mar 14 10:47 /tmp/configs/
file.cog
It should print:
-rw-r--r-- 1 owner group 3858 Mar 14 10:47 /tmp/configs/
file.config

It was my TERM truncating it, not Perl, no problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top