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?"
| [reply] |
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
| [reply] [d/l] |
|
| [reply] [d/l] |
|
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.
| [reply] [d/l] [select] |
|
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
| [reply] [d/l] |
|
|
|
|
|
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.
| [reply] |
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.
| [reply] |
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.
| [reply] |