Hello,
I want to capture the text being printed on console.
problem description is as follows.
I am calling called.pl program from caller.pl program using backticks.
in called.pl program i am giving an external command to be executed in backticks.
that external application will through a message to the console if any arguements are missing for that command.
for example if we are not sending username and password(or wrong username and password) which will be validated by that external program and if they are not found, it will through a message to console.
i want to capture that message and based on that message i need to trigger some events.
presently i am not able to capture any console text other than print stmts in external program which is called from called.pl using backticks.
can anybody help me in capturing that text.
thanks in advance.
regards,
Mohan.
3 2210 KevinADC 4,059
Recognized Expert Specialist
your premise is just wrong from the get go. You don't want to try an capture console output, you want to write a function into your script that does something if the user input is incorrect. Now there is a module that communicates with the standard output of applications, Expect, and you can tell your perl program to do stuff by parsing the output using the Expect module, but I don't know if that will work for you or not. You can look into it though and see if it will. I think it will need to be installed though.
Hi kevin,
Thanks for your reply.
I am working in windows machine where i dont have permissions to install any modules.
As i observed Expect.pm is not present in ActivePerl core distribution.
here my concern is to capture the output printed by that external program (for example .. "You do not have sufficient privileges..").
But as i observed is that with Expect module we can spawn a child and control it with in our program like we will through a user defined message if the spawning of the program fails... but not the error message returned by the external program.
Please suggest me can i achieve it in any other way.
Please correct me if i am wrong.
Thanks,
Mohan.
your premise is just wrong from the get go. You don't want to try an capture console output, you want to write a function into your script that does something if the user input is incorrect. Now there is a module that communicates with the standard output of applications, Expect, and you can tell your perl program to do stuff by parsing the output using the Expect module, but I don't know if that will work for you or not. You can look into it though and see if it will. I think it will need to be installed though.
KevinADC 4,059
Recognized Expert Specialist
Well, I don't think Expect even works on Windows unless maybe you install cygwin. My suggestion is you look into one of the Win32 modules that comes with your distribution of ActivePerl. There might be one that does this very thing but I do not know of one off the top of my head. So search through all the Win32 modules documentations and see if you get lucky.
Or maybe someone else will know of something.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Moosebumps |
last post by:
I have a large set of Python scripts that interface with command line
utilities (primarily Perforce). I am currently capturing ALL the text
output in order to get results and such. I am using the popen functions to
get the stdout, stderr streams.
However, some of the operations take a really long time (copying large files
over the network). If you run Perforce directly (or through os.system,
which doesn't return text output), it shows...
|
by: Oz |
last post by:
This is long. Bear with me, as I will really go through all the convoluted
stuff that shows there is a problem with streams (at least when used to
redirect stdout).
The basic idea is that my application (VB.NET) will start a process,
redirect its stdout and capture that process' output, displaying it in a
window.
I've written a component for this, and a test application for the component.
It allows me to specify a command to execute,...
|
by: Tim Marshall |
last post by:
In an A97 app I'm redeveloping, I've got a field in a table called
TS_LAST_PRINT which indicates the last date this record was printed.
That is a hard copy was produced, not an on screen print preview.
I'm sure I can capture this in code in a proc which does the
docmd.printout or a DoCmd.RunCommand acCmdPrint.
But what I'm worried about are more savvy users who just go Ctrl-P.
Any suggestions on how to capture this keyboard...
|
by: D. Bron |
last post by:
Group,
Is there any way to capture System.Console.Out output in the IDE? as it
stands, anything that gets printed to the console is lost once the
application exits.
-D. Bron
|
by: jcdperf |
last post by:
Hello,
I have small problems while reading of text files containing
accentuated characters. (like é è à ç ...). I use this basic code :
Dim sr As StreamReader
Try
sr = New StreamReader(sFichier)
Dim sLine As String
| |
by: Slack |
last post by:
I wish to write a console text editor. Can anyone tell me how to
capture the screen like Vi or Pico does?
Also, I wish to draw "tabs" on the screen, is there a standard way to
draw so that my code is crossplatform and will compile on most
platforms?
Thanks,
-Jason
|
by: Claude Yih |
last post by:
Hi, everyone. I got a question. How can I identify whether a file is a
binary file or an ascii text file? For instance, I wrote a piece of
code and saved as "Test.c". I knew it was an ascii text file. Then
after compilation, I got a "Test" file and it was a binary executable
file. The problem is, I know the type of those two files in my mind
because I executed the process of compilation, but how can I make the
computer know the type of a...
|
by: Ed Leafe |
last post by:
I've been approached by a local business that has been advised that
they need to start capturing and archiving their instant messaging in
order to comply with Sarbanes-Oxley. The company is largely PC, but
has a significant number of Macs running OS X, too.
Googling around quickly turns up IM Grabber for the PC, which would
seem to be just what they need. But there is no equivalent to be
found for OS X. So if anyone knows of any such...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |