mrkrinkle has asked for the wisdom of the Perl Monks concerning the following question:

Ok so- I have a .pl file that prints to cli:

print "wpeofkwpoef";

If I run the .pl directly, it prints just fine. ./damnit.pl

I have an ln -s link to it in /usr/local/bin/damn.

If I run it from cli there /usr/local/bin/damn, it runs (the code later on even changes files; it works), but it never prints.

This same code usta work in perl like 15 years ago lol.

important to note to test, I made .sh script that just does:

#!/bin/bash
echo 'wefwe';

And then did an ln -s to it and it prints the wefew. So .sh can do that from the link but perl demands it be done from the actual file not the link.

Ubuntu 18.04 $ perl -v This is perl 5, version 26, subversion 1 (v5.26.1) built for x86_64-linux-gnu-thread-multi (with 67 registered patches, see perl -V for more detail)

Thanks monks, sorry for the lack of < code> tags but the code is so minimal. m
  • Comment on printing to stdout from a soft ln -s doesn't show up

Replies are listed 'Best First'.
Re: printing to stdout from a soft ln -s doesn't show up
by Fletch (Bishop) on Sep 16, 2020 at 19:15 UTC

    Another possibility which can happen is that since you're not printing a newline on your (*aherm*) code sample that your shell's prompt is overwriting the output (maybe even more likely if you've got a fancy prompt with angry fruit salad or multiple lines). Add a call to echo afterwards but on the same command line ( e.g. whatever ; echo ) and I'd bet you'd see the output then.

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

Re: printing to stdout from a soft ln -s doesn't show up
by haukex (Archbishop) on Sep 16, 2020 at 18:23 UTC
    If I run it from cli there /usr/local/bin/damn, it runs (the code later on even changes files; it works), but it never prints.

    I find it extremely unlikely the softsymbolic link has anything to do with it, plus I can't reproduce it.

    $ cat foo.pl #!/usr/bin/env perl use warnings; use strict; print "wpeofkwpoef\n"; $ chmod 700 foo.pl $ ./foo.pl wpeofkwpoef $ sudo ln -s /tmp/foo.pl /usr/local/bin/foo $ foo wpeofkwpoef
    Thanks monks, sorry for the lack of < code> tags but the code is so minimal.

    Well, you're going to have to give us some way to reproduce the issue... see SSCCE and I know what I mean. Why don't you?

    Just a guess: are you running your link in /usr/local/bin directly from the command line, or some other way? If it's the latter, then I suspect the cause to be there somewhere.

Re: printing to stdout from a soft ln -s doesn't show up
by marto (Cardinal) on Sep 16, 2020 at 18:32 UTC

    Ubuntu 20.04.1, perl 5.30.0, can't reproduce the problem:

    marto@Marto-Desktop:~/code$ perl print.pl wpeofkwpoefmarto@Marto-Desktop:~/code$ chmod +x print.pl marto@Marto-Desktop:~/code$ ln -s print.pl test marto@Marto-Desktop:~/code$ ./test wpeofkwpoefmarto@Marto-Desktop:~/code$ cd /usr/local/bin/ marto@Marto-Desktop:/usr/local/bin$ sudo ln -s $HOME/code/print.pl der +p marto@Marto-Desktop:/usr/local/bin$ derp wpeofkwpoefmarto@Marto-Desktop:/usr/local/bin$ ./derp wpeofkwpoefmarto@Marto-Desktop:/usr/local/bin$

    Perhaps your terminal session was somehow messed up, or maybe you have some weird shell customisation that's clobbering this? If you do some test does it display anything?

    #!/usr/bin/perl print "wpeofkwpoef" or die "Can't print to stdout: $!";

    If it still doesn't print anything try redirecting:

    derp &>derplog
Re: printing to stdout from a soft ln -s doesn't show up
by mrkrinkle (Novice) on Sep 16, 2020 at 19:31 UTC
    Ok guys I figured it out. I my ln -s was linking to the wrong .pl file. *forehead-smack*. 90% of all problems are either permissions or wrong file paths. Thanks as always, monks.
Re: printing to stdout from a soft ln -s doesn't show up
by perlfan (Parson) on Sep 17, 2020 at 00:28 UTC
        Because this node will show up if someone searches for "printing to stdin doesn't show up", which is indeed related to my answer.