Why do my Perl backlinks complain "sh: line 1: any: command not found"?

I have never programmed before, but I needed to write a very simple webapp to work.

I am trying to run this query:

dig @8.8.8.8 +nocomments +nostats +noquestion +nocmd google.com any

With this perl bit:

$dig = `/usr/bin/dig \@8.8.8.8 +nocomments +nostats +noquestion +nocmd $query any`;

Except that he does not seem to recognize “anyone” at the end of digging and gives me:

sh: line 1: any: command not found

What nonsense am I doing wrong?

+3
source share
3 answers

I put that $queryhas a new line in it, making your shell see anyas a new command.

Try this chomp $query;before calling the system to delete a new line. Read more about chomp .

+11
source

, dig ... '$query', , . , . - "; echo my_key > ~/.ssh/authorized_keys" -, . , , , - - ( , .)

perl

\Q$query\E
, $ \. , , , , . - . .

Perl system(), args , /bin/sh, , . , , && fork && .

+2

Most likely, this is what the $ query variable violates the command line. Can you give us an example where it does not work and gives an error? Or show a little more of your script?

+1
source

Source: https://habr.com/ru/post/1724800/


All Articles