Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

different terminal

by ivanradix (Initiate)
on Jun 10, 2014 at 11:19 UTC ( [id://1089406]=perlquestion: print w/replies, xml ) Need Help??

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

Hi all, I have some applications running on a Linux and if i like to execute some commands i have to get in to the application terminal and execute the commands that iv used. So what im trying to achieve here is to execute this commands from the linux machine to skip get to other terminal/i.e applicational terminal. For example to list something i have to type something liket this in linux first: 1. terminal_application 2. execute some commands 3. output. and 4. exit from terminal and back to linux. I would like to make something to skip step 1 and 3 .. just execute the perl script and gave me the output on a linux terminal. Application or the terminal application are on the same machine, different terminal different commands ect. but same machine. Im stuck to get to other terminal. i dont know way.

Replies are listed 'Best First'.
Re: different terminal
by Anonymous Monk on Jun 10, 2014 at 14:04 UTC

    I am interpreting your description to mean that you are currently manually typing some commands into a terminal window to get their output, and you'd like to automate that.

    Take a look at the modules IPC::System::Simple and IPC::Run3.

    If you need more specific help with some code, please post the code along with a description of what it's supposed to be doing and how that's different from what it's actually doing, some sample input, the expected output, and any error messages you may be getting. See also "How do I post a question effectively?" and "I know what I mean. Why don't you?"

Re: different terminal
by blue_cowdawg (Monsignor) on Jun 10, 2014 at 16:53 UTC
        nd if i like to execute some commands i have to get in to the application terminal and execute the commands that iv used.

    if you re running in a Linux environment and want a script to collect the results of running a command (or commands) why bother with a terminal at all? Something like this should work (weak example):

    #!/usr/bin/perl -w use strict; my $cmd=qq@ date who ps -ef netstat -i ifconfig -a ) | @; open CMD, $cmd or die $cmd . ":$!"; my @lines=<CMD>; # slurp! close CMD; chomp @lines; # do something here.


    Peter L. Berghold -- Unix Professional
    Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg

      I'm curious what the ) | does.

      1 Peter 4:10

        | opens a pipe (see perldoc perlopentut). ( ... ) delimits a subshell, and can be tested at the command line:

        davido@somehost:~$ ( > date > who > ) Tue Jun 10 11:20:34 MDT 2014 davido :0 2014-06-09 19:35 (:0) davido pts/0 2014-06-09 19:38 (:0)

        See This stackexchange explanation.


        Dave

        It works better without the ")".

        With it, the shell complains:

        sh: 6: Syntax error: ")" unexpected
        but the output is produced anyway.

                What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?
                      -Larry Wall, 1992

Re: different terminal
by zentara (Archbishop) on Jun 10, 2014 at 13:14 UTC
    i dont know w<h>ay.

    From your explanation, neither do we. Explain it better, and/or show some sample code.


    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
Re: different terminal
by GotToBTru (Prior) on Jun 10, 2014 at 14:36 UTC

    If you want to be able to execute commands without the effort of opening up a terminal session and typing them, you could create a shell script to do it.

    1 Peter 4:10
Re: different terminal
by sundialsvc4 (Abbot) on Jun 10, 2014 at 14:30 UTC

    Yes, more clarification is needed.   For example, “where are you right now, and where do you need to go?”   Is the target application on the same computer, or a different one?   What sort of computer is your present host, and what sort of computer is your target?   Is Perl “driving the bus” here, or is it merely the “passenger” at the destination?   The list goes on.   Many of us have very-surely encountered this sort of obstacle before, but there are a great many variations of that obstacle!   :-D

    If, for example, you are running a GUI application that needs to execute a command-line command and to retrieve the results thereof, that is straightforward to do.   But first, so as not to oblige us to indulge in speculations that might or might not be apropos, please clarify what you intend to do.

    For example:

    “The absolutely perfect solution to my immediate problem, if only I knew how to do it, would look like this:   _________.”
    (Fill in the blank, in detail.)

    Tell us that, and we can swiftly tell you (several ways) how to do it.   Looking forward to your reply.

Re: different terminal
by ivanradix (Initiate) on Jun 11, 2014 at 09:47 UTC

    Well you all have right! Thanks you to all for reply. I was not sure how this work with terminals. When i go from one terminal to another, but i get clear now thank you all.

    I have now some problems When i execute the command from Cygwin ( using windows ) i have the folowing "ssh root@servername list all app" where "list all app" is the command from the other terminal as i mention above, i get some list of app names. So what im trying to do here is make a perl script ( im noob ye :) learning ) that will execute this command and gave me the output on the same terminal as i am. ... as i do on Cygwn when i execute the above command i have the output.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1089406]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2024-04-25 20:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found