Execute Perl Script from Bash script

PowerMan2015

Ok so i have the following script to scrape contact details from a list of urls (urls.txt). When i run the following command direct from the terminal i get the correct result

perl saxon-lint.pl --html --xpath 'string-join(//div[2]/div[2]/div[1]/div[2]/div[2])' http://url.com 

however when i call the above command from within a script i get a "no such file or directory" result

Here is a copy of my script

#!/bin/bash

while read inputline
do
  //Read the url from urls.txt
  url="$(echo $inputline)"

  //execute saxon-lint to grab the contents of the XPATH from the url within urls.txt
  mydata=$("perl saxon-lint.pl --html --xpath 'string-join(//div[2]/div[2]/div[1]/div[2]/div[2])' $url ")

  //output the result in myfile.csv
  echo "$url,$mydata" >> myfile.csv

  //wait 4 seconds
  sleep 4

//move to the next url
done <urls.txt

i have tried changing the perl to ./ but get the same result

can anyone advise where i am going wrong with this please

The error that i am receiving is

./script2.pl: line 6: ./saxon-lint.pl --html --xpath 'string-join(//div[2]/div[2]/div[1]/div[2]/div[2])' http://find.icaew.com/listings/view/listing_id/20669/avonhurst-chartered-accountants : No such file or directory

Thanks in advance

glenn jackman

Don't put double quotes inside the command substitution.

Not:

mydata=$("perl saxon-lint.pl --html --xpath 'string-join(//div[2]/div[2]/div[1]/div[2]/div[2])' $url ")
# .......^...........................................................................................^

But this:

mydata=$(perl saxon-lint.pl --html --xpath 'string-join(//div[2]/div[2]/div[1]/div[2]/div[2])' $url )

With the double quotes, you're instructing bash to look for a program named "perl saxon-lint.pl --html etc etc" in the path, spaces and all, and clearly no such program exists.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Execute PowerShell script from Perl script

From Dev

Unable to execute a bash script in background from another bash script

From Dev

How to execute perl script from a Windows Powershell script

From Dev

Execute a perl script within a perl script with arguments

From Dev

Execute a perl script within a perl script with arguments

From Dev

How to execute git commands from bash script?

From Dev

Cannot execute Bash script from PHP

From Dev

How to execute a Bash script from Github?

From Dev

Execute bash script with params from Javascript

From Dev

Bash script to read from a file and execute commands

From Dev

Bash script to read from a file and execute commands

From Dev

Execute complex command from bash script

From Dev

Execute random file from a folder in a bash script

From Dev

Go: execute bash script

From Dev

How to execute a bash script?

From Dev

Bash Script - Will not completely execute

From Dev

Bash Command In Perl Script

From Dev

Bash Command In Perl Script

From Dev

Bash script failing to execute bash script

From Dev

Execute perl script with arguments in R

From Dev

Execute C++ program from Perl script; does it require a compiler?

From Dev

How to execute a Pl sql file from a perl script

From Dev

Is there a way to execute a perl script from any location in the machine?

From Dev

Perl replace produces empty file from script, not from bash

From Dev

Perl replace produces empty file from script, not from bash

From Dev

Unable to execute bash script inside expect script

From Dev

CoffeeScript - Execute bash script with arguments

From Dev

Bash Script to execute Java Project

From Dev

Execute gcloud commands in a bash script

Related Related

HotTag

Archive