I am trying to run a Perl script directly from GitHub. This thread seems to address my issue (indeed, it helped me run dofiles in Stata directly from GitHub). However, when I type the following in a command prompt:
"perl https://rawgit.com/EconJoe/medline2014-xmlparsers/master/desc2014_meshtreenumbers.pl"
I get The following error message:
"Can't open perl script "https://rawgit.com/EconJoe/medline2014-xmlparsers/master/desc2014_meshtreenumbers.pl": Invalid argument"
Thanks for any help.
perl can't fetch a script from a URL. You have to do that separately.
curl -L https://rawgit.com/EconJoe/medline2014-xmlparsers/master/desc2014_meshtreenumbers.pl | perl
Related
I call a perl script from shell script.Since both unix shell script and perl script are created by me, i was able to execute it successfully.But when i deploy the code using anthillpro, permission of the files changed to 644. Hence when others execute this shell script, they are able to run unix script but following error is received while calling perl script.
0403-006 Execute permission denied.
Following code is used to invoke my perl script from unix shell script:
/usr/bin/perl /home/script/conversion.pl $layout_file $format_file $conv_file $base_filenm $COREPATH
First line of my perl script has following line:
#!/usr/bin/perl
Can anyone provide a solution for this issue ?
i am trying to execute following unix command but its not getting executed
$array_of_tables= `dbsmp $srv_name`;
print "$array_of_tables\n";
please help me to find out list of tables in a data base through perl scripting.
Also i am trying to copy a file from a path to different path by using following command:-
copy(`cd /osp/slee/service/$srv_name/bin/exec/script.txt`,`cd /osp/local/home/linus/amit/scripts`);
but getting an error:-
Usage: copy(FROM, TO [, BUFFERSIZE])
please provide some solution
Thanks
Use doublequotes instead of back ticks.
copy("/osp/slee/service/$srv_name/bin/exec/script.txt","/osp/local/home/linus/amit/scripts");
and remove the cd
In Perl, the preferable way to capture the output of a system (shell) command is the qx() operator. See http://perldoc.perl.org/perlop.html#Quote-Like-Operators.
$array_of_tables = qx(dbsmp $srv_name);
print("$array_of_tables\n");
Actually, backticks should also work, so the problem must lie with your dbsmp command. I'm not sure what that command is; you'll have to provide more information about the utility and what error you're seeing.
For comparison, I can retrieve the list of tables in my local postgres database as a pipe-separated table using this shell command:
> psql -tAXq main postgres <<<\\d;
And this can be run from Perl as follows:
> perl -e 'print(qx(psql -tAXq main postgres <<<\\\\d;));'
I wrote a shell script that I use under ash, and I redirect stderr and stdout to a log file. I would like that log file to be emailed to me only if stderr is not empty.
I tried:
exec >mylog.log 2>&1
# Perform various find commands
if [TEST_IF_STDERR_NOT_EMPTY]; then
/usr/bin/mail -s "mylog" email#mydomain.com < mylog.log
fi
My question is twofold:
1- I get a -sh: /usr/bin/mail: not found error. It seems that the mail command doesn't exist under ash (or at least under my linux box, which is a Synology NAS), what would be the alternative? Worst case, perl is available, but I would prefer to use standard sh commands.
2- How to I test that stderr is not empty?
Thanks
How to check if file is empty in bash
As for the first question, in your code you are calling mail but lower in the post you are calling email. Check your code and make sure it is mail.
Use which mail to get the full path. Maybe it is not installed in /usr/bin/.
Use find to locate mail.
If you can go to another shell, run it and then execute which mail to get the full path of mail in case the path is set up in the alternative shells.
I have a perl file (eg:test.pl) which does some DB operations.
While testing, its working fine.
I execute this file as a background process by using the command
perl test.pl &
Its working properly for some days.
But after some days ,the file execution get stopped.
How can I find the reason or view the error?
I checked the log file "/var/log/httpd/error_log", but can't find anything.
I keep the perl file in a server, which runs in Cent OS.
Any one have idea?
There is no 'perl error log'
But you can define a destination for output to be saved to, just run your script like this:
perl test.pl >> /var/log/some-log-file.log 2>&1 &
This will redirect STDOUT (normal shell output) and STDERR (error output) to /var/log/some-log-file.log instead of to the terminal.
You may also wish to use nohup in order to have the script ignore HANGUP (logout) signals, which could be causing your unexpected terminations:
nohup perl test.pl >> /var/log/some-log-file.log 2>&1 &
Obviously, whichever user you run the script as will need to have write access to the log file.
I'm beginning to write a simple Perl program on my Mac, and I understand that the first line needs to be the location of Perl itself, every example or tutorial I find tells me the first line should be:
"#!/usr/bin/perl"
However, with that there, I attempt to run the file under localhost and I get this error:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, you#example.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Anyone have any idea why this is happening?
Thanks in advance, and let me know if any more information is needed!
P.S. if it helps, when I execute the command: "perl -v" it tells me
This is perl, v5.10.0 built for darwin-thread-multi-2level
(with 2 registered patches, see perl -V for more detail)
As Erik said, /usr/bin/perl is the standard location for Perl on OSX. You can also verify this by running which -a perl from terminal (this will list all instances of Perl on your path).
Can you run your script from the command-line, i.e. ./<myscript>.pl? It's possible that you haven't made the script executable.
#!/usr/bin/perl is the correct path for 10.6. If you're running from the webserver, your first line before any output should be a HTML header. You may have forgotten one?
#!/usr/bin/perl
use CGI;
print CGI->header('text/html');
print "hello world";