I have the following script (json_test) on a remote FreeBSD virtual machine which runs fine when executed directly on the VM:

#!/usr/bin/env perl use lib "/home/user/perl5/lib"; use JSON; # line 4 print JSON->new->pretty->encode( { qw( a b ) } );

However, I get the following error message when I try to run it via SSH from my local machine:

leudwinus@localmachine:~$ ssh user@remotemachine './json_test' Can't locate JSON.pm in @INC (you may need to install the JSON module) + (@INC contains: /home/user/perl5/lib /usr/local/lib/perl5/site_perl/ +mach/5.32 /usr/local/lib/perl5/site_perl /usr/local/lib/perl5/5.32/mach /usr/loc +al/lib/perl5/5.32) at ./json_test line 4. BEGIN failed--compilation aborted at ./json_test line 4.

Any suggestions on how I can execute this script remotely via SSH?

On the virtual machine, I get the following information:

user@remotemachine:~$ perldoc -l JSON /home/user/perl5/lib/perl5/JSON.pm user@remotemachine:~$ perl -V Summary of my perl5 (revision 5 version 32 subversion 1) configuration +: ... @INC: /home/user/perl5/lib/perl5/5.32.1/amd64-freebsd-thread-multi /home/user/perl5/lib/perl5/5.32.1 /home/user/perl5/lib/perl5/amd64-freebsd-thread-multi /home/user/perl5/lib/perl5 /home/user/perl5/lib/perl5/5.32.1/amd64-freebsd-thread-multi /home/user/perl5/lib/perl5/5.32.1 /home/user/perl5/lib/perl5/amd64-freebsd-thread-multi /home/user/perl5/lib/perl5 /usr/local/lib/perl5/site_perl/mach/5.32 /usr/local/lib/perl5/site_perl /usr/local/lib/perl5/5.32/mach /usr/local/lib/perl5/5.32

JSON is installed on my local Ubuntu machine at /home/leudwinus/perl5/lib/perl5/JSON.pm but I didn't think that would matter.

Thanks in advance!


In reply to Can't locate module in @INC when executing script over SSH by Leudwinus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.