Sponsored Content
Top Forums UNIX for Advanced & Expert Users Complex Input/Output Redirect Post 302421840 by dnbert on Sunday 16th of May 2010 07:23:24 PM
Old 05-16-2010
Yes, use Expect. And input the variables into your ARGV array (or the comparable for bash).
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

please help: how to redirect input into a variable

I'm trying to write a simple script program (C shell). I have a problem redirecting input into a variable. Say I have a variable called J, and there is file called result which contains just some number, say 5. Which command should I use to assign J value 5 from the file result. I tried the... (2 Replies)
Discussion started by: artur80
2 Replies

2. UNIX for Dummies Questions & Answers

redirect input from file?

I need to run a command inside root-environment, and want to use: su - root -c "some command..." Then I am prompted for a password, of course. Is it possible to put this password in a file, and present this files content, to the command above?:confused: (1 Reply)
Discussion started by: bjornrud
1 Replies

3. Shell Programming and Scripting

Input file redirect in output path and want name as inputfilename_new.txt

not required this time (6 Replies)
Discussion started by: Sandeep_Malik
6 Replies

4. Programming

Redirect input and output to a shell script?

Dear All: I am trying to do something that (I thought) was relatively straightforward, but my code snippet does not seem to work. Any suggestions? Thank you Sincerely yours Misha Koshelev #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <errno.h> #include... (0 Replies)
Discussion started by: misha680
0 Replies

5. Shell Programming and Scripting

redirect an awk string output to a script input with pipes

Hi, I have a function in a bash script that returns a string after some operations using awk. The following code returns 555 $VARIABLE="EXAMPLE" get_number $VARIABLE this value I'd like to pass it as a second argument of another script with the following usage myscript.sh <param1>... (7 Replies)
Discussion started by: rid
7 Replies

6. Shell Programming and Scripting

Complex overlap and naming of 2 input files - Awk

for every specific $1,$2 check the values ($2,$3) of their E ot I of input1 and overlap with input2. Specify names based on output. ####### if middle value is missing name them "SE" if first value is missing name them "AFE" if last value is missing name them "ALE" if 2 middle values are... (1 Reply)
Discussion started by: ruby_sgp
1 Replies

7. Shell Programming and Scripting

script to mail monitoring output if required or redirect output to log file

Below script perfectly works, giving below mail output. BUT, I want to make the script mail only if there are any D-Defined/T-Transition/B-Broken State WPARs and also to copy the output generated during monitoring to a temporary log file, which gets cleaned up every week. Need suggestions. ... (4 Replies)
Discussion started by: aix_admin_007
4 Replies

8. Shell Programming and Scripting

Read file from input and redirect to output file

Hi , i am having an file which contains 5 file_name data, i need to read the file name and will perform certain operation and generate out file names with named as 5 individual file_names for eg: file.txt contains file_name1.txt|hai file_name2.txt|bye file_name3.txt|how... (3 Replies)
Discussion started by: rohit_shinez
3 Replies

9. Shell Programming and Scripting

Redirect script output to a file and mail the output

Hi Guys, I want to redirect the output of 3 scripts to a file and then mail the output of those three scripts. I used below but it is not working: OFILE=/home/home1/report1 echo "report1 details" > $OFILE =/home/home1/1.sh > $OFILE echo... (7 Replies)
Discussion started by: Vivekit82
7 Replies

10. UNIX for Dummies Questions & Answers

Redirect output to the same input file in awk

Hi, I want to compare a value from test file and redirect the o/p value to the same file input file 250 32000 32 128 Below is my code awk '{ if ($1 < "300") print $1 > /tmp/test}' test want to compare 250 < 300 then print 300 to the same place below is the... (24 Replies)
Discussion started by: stew
24 Replies
Expect::Simple(3pm)					User Contributed Perl Documentation				       Expect::Simple(3pm)

NAME
Expect::Simple - wrapper around the Expect module SYNOPSIS
use Expect::Simple; my $obj = new Expect::Simple { Cmd => [ dmcoords => 'verbose=1', "infile=$infile"], Prompt => [ -re => 'dmcoords>:s+' ], DisconnectCmd => 'q', Verbose => 0, Debug => 0, Timeout => 100 }; $obj->send( $cmd ); print $obj->before; print $obj->after; print $obj->match_str, " "; print $obj->match_idx, " "; print $obj->error_expect; print $obj->error; $expect_object = $obj->expect_handle; DESCRIPTION
"Expect::Simple" is a wrapper around the "Expect" module which should suffice for simple applications. It hides most of the "Expect" machinery; the "Expect" object is available for tweaking if need be. Generally, one starts by creating an Expect::Simple object using new. This will start up the target program, and will wait until one of the specified prompts is output by the target. At that point the caller should send() commands to the program; the results are available via the before, after, match_str, and match_idx methods. Since Expect simulates a terminal, there will be extra " " characters at the end of each line in the result (on UNIX at least). This is easily fixed: ($res = $obj->before) =~ tr/ //d; @lines = split( " ", $res ); This is not done automatically. Exceptions will be thrown on error (match with "/Expect::Simple/"). Errors from Expect are available via the error_expect method. More human readable errors are available via the error method. The connection is automatically broken (by sending the specified disconnect command to the target) when the Expect::Simple object is destroyed. Methods new $obj = Expect::Simple->new( \%attr ); This creates a new object, starting up the program with which to communicate (using the Expect spawn method) and waiting for a prompt. The passed hash reference must contain at least the Prompt, DisconnectCmd, and Cmd elements. The available attributes are: Cmd Cmd => $command, Cmd => [ $command, $arg1, $arg2, ... ], The command to which to connect. The passed command may either be a scalar or an array. Prompt This specifies one or more prompts to scan for. For a single prompt, the value may be a scalar; for more, or for matching of regular expressions, it should be an array reference. For example, Prompt => 'prompt1> ', Prompt => [ 'prompt1> ', 'prompt2> ', -re => 'promptd+>s+' ] All prompts are taken literally, unless immediately preceded by a "-re" flag, in which case they are regular expressions. DisconnectCmd This is the command to be sent to the target program which will cause it to exit. RawPty If set, then underlying Expect object's pty mode is set to raw mode (see Expect::raw_pty()). Timeout The time in seconds to wait until giving up on the target program responding. This is used during program startup and when any commands are sent to the program. It defaults to 1000 seconds. Debug The value is passed to Expect via its debug method. Verbose This results in various messages printed to the STDERR stream. If greater than 3, it turns on Expect's logging to STDOUT (via the log_stdout Expect method. send $obj->send( $cmd ); $obj->send( @cmds ); Send one or more commands to the target. After each command is sent, it waits for a prompt from the target. Only the output resulting from the last command is available via the after, before, etc. methods. match_idx This returns a unary based index indicating which prompt (in the list of prompts specified via the "Prompt" attribute to the new method) was received after the last command was sent. It will be undef if none was returned. match_str This returns the prompt which was matched after the last command was sent. before This returns the string received before the prompt. If no prompt was seen, it returns all output accumulated. This is usually what the caller wants to parse. Note that the first line will (usually) be the command that was sent to the target, because of echoing. Check this out to be sure! after This returns the 'after' string. Please read the Expect docs for more enlightenment. error This returns a cleaned up, more humanly readable version of the errors from Expect. It'll be undef if there was no error. error_expect This returns the original Expect error. expect_handle This returns the Expect object, in case further tweaking is necessary. BUGS
If the command to be run does not exist (or not in the current execution path), it's quite possible that the new method will not throw an exception. It's up to the caller to make sure that the command will run! There's no known workaround for this. LICENSE
This software is released under the GNU General Public License. You may find a copy at http://www.fsf.org/copyleft/gpl.html AUTHOR
Diab Jerius (djerius@cpan.org) perl v5.12.4 2008-05-06 Expect::Simple(3pm)
All times are GMT -4. The time now is 04:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy