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

That must be very easy, but I can not solve this. I have a perl program starting at reboot. When I connect the gps logger to the computer it is recognized by the program and starts program to download the data from logger to computer. When I run the program from the terminal I get all output to the terminal, but when program is started at reboot, I connect my logger, program does what is should do, but I would like to have terminal window open with output showing. Any ideas?? Thanks as always Robert

Replies are listed 'Best First'.
Re: Getting output to terminal
by wrog (Friar) on Aug 01, 2014 at 23:41 UTC

    What kind of computer are we talking about (desktop PC or mac? rackmount server? laptop? smartphone?)? What operating system (windows? mac? linux? ios? android?)?

    The big problem here is that, in general, since one of the tasks of the reboot is to create references to all of the various devices that are hooked up and then start all of the various background services that your system needs to have running in order to be "up", the display on which any such terminal window might appear won't necessarily exist yet (and if it's a rackmount server, never actually will). Most likely the best you're ever going to be able to do is have your program write a file somewhere for later consumption.

    And then, most likely, you won't want any windows appearing showing that file until/unless you log in (after the reboot is complete), at which point the question is then how you're actually logging in, which will most likely then indicate the best way of getting something to automatically start up that will display the file that your program has produced (or is producing), i.e., if your program has indeed run and produced any file at all, which it might not have.

      Sorry about lack of specifics, I was desperate writing last message. Computer: Dell XPS13 with Ubuntu 12.04. Again the plan is to pop up terminal/console window when gps logger is connected and displaying output of the process in that window. SO in summary I would like for perl program to open up new terminal window and display it's output there. Thanks Robert

        Hi Monks, I think I start getting sme ideas. Below is a code that still does not work and I do not know why

        #!/usr/bin/perl use strict; use warnings; `gnome-terminal &`; open (my $OUT, '>>','/dev/pts/2'); select $OUT; while(1) { print "Testing on this termianal\n"; sleep(1); }

        I have to go as root to open $OUT, but still nothing comes on new terminal windows. I did check and and new terminal is /dev/pts/2. Any ideas?? Robert

Re: Getting output to terminal
by BillKSmith (Monsignor) on Aug 02, 2014 at 14:31 UTC
    It is possible that your program does write its output to a terminal window then terminate. The window closes before you have chance to read it. In this case, your program should either pause or prompt for operator acknowledgement before terminating.
    Bill
Re: Getting output to terminal
by Anonymous Monk on Aug 02, 2014 at 23:03 UTC

    Do not worry about the console in the Perl program. Have your Perl program write to a file. Use tail -F to watch that file from a console. There are many ways you can get your console to open up automatically, for example your windowing system should support some kind of autostart of applications. Look into udev for how to start applications when a USB device is connected.

      Now story is getting more interesting. The script that I attached works on one computer with Ubuntu 14.04, does not work with Ubuntu 12.04 ( I do not think version of Ubuntu matter here) . Script does not want to print to the terminal window that script initiated and opened. It will however sent data and print into terminal windows that is already open. Interesting, any ideas??

        If by attached you mean the above, my opinion is that you're doing things backwards. The terminal should be running a command (such as your script or tail) and showing its output (e.g. gnome-terminal -e 'tail -F /var/log/syslog'), instead of the script opening a terminal and trying to hack the output into there somehow. Don't do it that way, and do it as described in the parent above, you'll arrive at a working, more reliable solution faster.