CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate: Problem opening cmd output as file using xargs: Edit Log



cben
New User

Nov 29, 2016, 9:30 AM


Views: 11502
Problem opening cmd output as file using xargs

I'm trying to debug a program that uses xargs to feed a file of hex addresses (one per line) to addr2line. The output is piped to an open command to be read in and used later.

I didn't write the program but after days of debugging, I realize I need some help.

Here's the subroutine in question:

Code
sub src_line_info { 
my ($addr2line, $exec) = @_;
my ($cmd) = "xargs $addr2line -e $exec";
my ($tmpfile) = tmpnam();
my (@a2loutput);

open(ADDRS, ">$tmpfile") or die "open($tmpfile) failed: $!\n";
foreach my $ra (@trace_addrs) {
print ADDRS "$ra->[TADDR_ADDRESS]\n";
}
close(ADDRS);

$cmd = "$cmd < $tmpfile |";

open(LINES, $cmd) or die "open($cmd) failed: $!\n";
while (<LINES>) {
chomp();
push(@a2loutput, [split(/:/, $_)]);
}
close(LINES);
.
.
.
}

The problem is that either the "open(LINES, $cmd)" or "while(<LINES>)" is returning the following error message:

"sh: /sw/packages/findutils/4.1/bin/xargs: Permission denied"

I've verified that:
- addr2line is executable
- tmpfile is readable
- the $exec file is rwx
- xargs is -rwxr-xr-x. 1 4294967294 4294967294 64484 Oct 28 2003 /sw/packages/findutils/4.1/bin/xargs
- the open command error message is not output
- I can execute the command line in $cmd with out the "|" manually

I tried executing xargs with -p to make it prompt so I could see if there was a specific error message from the temp file that wasn't coming back that I could check, but it didn't work.

I've used different files to ultimately generate the tmpfile, so it isn't the tmpfile itself that is the problem.

I'm out of ideas. Any help is appreciated.

One final thing. This code is from a build tree and will be invoked mechanically by a tool, so I can't really modify it directly. I will have to find ways to modify the code it calls (addr2line/xargs versions, etc). But I can modify it to debug it and figure out what's going on if you have any ideas on that front.

Many thanks!!


(This post was edited by FishMonger on Nov 29, 2016, 10:00 AM)


Edit Log:
Post edited by FishMonger (Veteran) on Nov 29, 2016, 10:00 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives