0

I'm a perl novice. What's happening inside the backticks of the following?

$selfext and $banner are previously defined. The statement below is executed in Linux and I don't understand where the banner function is coming from? When I print $_ I get a null string.

$_=`banner $selfext $banner`;
Jason K Lai
  • 1,500
  • 5
  • 15
BilgeRat
  • 1
  • 1
  • 1
    Can you show the contents of `$selfext` and `$banner`? In Perl, an expression in backticks is executed as a system call and its output is returned as a string. Here, you are assigning that output to `$_`. If it is empty, then the `banner` command probably didn't produce any output. – joanis Jul 12 '19 at 20:26
  • Note that the code appears to suffer from [code injection](https://en.wikipedia.org/wiki/Code_injection) bugs. – ikegami Jul 12 '19 at 21:11
  • joanis, Thanks. selfext is null and banner="results" – BilgeRat Jul 12 '19 at 21:15

1 Answers1

2

This is invoking a shell which is executing the banner command. banner is a normal UNIX program like uniq, sort or even perl itself, i.e. this is not some perl function. It is not installed on all systems though (same as with perl) and therefore the execution might fail. For more see man banner.

melpomene
  • 84,125
  • 8
  • 85
  • 148
Steffen Ullrich
  • 114,247
  • 10
  • 131
  • 172