07-21-2014
Thanks both work fine and good enough for me.
In the second example, what kind of redirection is <&3 and then 3< ?
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I'm trying to pass a filename, or all the files in the current directory to the ls command with a script. Unsuccessful so far, here are a few of my attempts:
#!/bin/ksh
read fname
#if (( $# > 0 )); then
$fname | ls -l
#fi
this produces a long listing of all the files in my current... (4 Replies)
Discussion started by: jpprial
4 Replies
2. Shell Programming and Scripting
Hi,
I have a script which adds the user credentials to an ldap server. Im passing the variables as below..
/path/my_script $uname $pwd $environ ${deposit}
If i enter some special characters like ';' in $pwd, script returns an error which is set to display if the user enters... (5 Replies)
Discussion started by: Tuxidow
5 Replies
3. Shell Programming and Scripting
Hi
I have a script to which I pass multiple arguments, for example lets say the script name is "abc". I run the script like
./abc def /file <directory location>
In the above "def" is the first argument and "/file" is the second argument. I expect <directory location> that is passed after... (4 Replies)
Discussion started by: zmfcat1
4 Replies
4. UNIX for Dummies Questions & Answers
I need to pass arguments to a shell script.My batch is calling some java program.
#################
x=$1
y=$2
java -classpath program
###################
if first parameter and second parameter is null then
java -classpath program
if first parameter is not null and second parameter is... (3 Replies)
Discussion started by: mnjx
3 Replies
5. Shell Programming and Scripting
Hi ..
Can any one please tell how to pass argument to shell script at runtime?
I want to implement funcnality just like bc, where we can provide input while script is running and can be used later in the same script.
Thanks in advance... (1 Reply)
Discussion started by: kunjalhg
1 Replies
6. Programming
Is there any way I could pass arguments to shellcode. My goal is to store a program in a image file, and have another program read and run the code with arguments in memory.
Currently I can store a program in a image file, then read it back to the hard-drive run it normally then delete it when... (5 Replies)
Discussion started by: image28
5 Replies
7. Shell Programming and Scripting
I have an for loop that reads the following file
cat param.cfg
val1:env1:opt1
val2:env2:opt2
val3:env3:opt3
val4:env4:opt4
.
.
The for loop extracts the each line of the file so that at any one point, the value of i is
val1:env1:opt1 etc...
I would like to extract each... (19 Replies)
Discussion started by: goddevil
19 Replies
8. Shell Programming and Scripting
Hi,
i have a file.txt with data
Bangalore
Chennai
Hyd
filename of the script is: new.sh
result=`cat file.txt | grep $1`
if
then
echo pass
else
echo fail
fi
i am executing the file in the cmd line as "sh new.sh Bangalore"
o/p is pass
if i give "sh new.sh delhi"
o/p is... (6 Replies)
Discussion started by: harsha85
6 Replies
9. Shell Programming and Scripting
hi All,
i am trying to pass arguments that contain space , value will be stored in variables to be used further in script , i went thru previous posting , still its not clear to how to implement for my case.
passing 3 args
test.sh it is 'fun to work in unix'
inside shell
... (3 Replies)
Discussion started by: gvkk
3 Replies
10. Shell Programming and Scripting
Dear Users,
I have installed a standalone program to do multiple sequence alignment which takes user parameters to run the program. I have multiple sequence files and want to automate this process through a bash script. I have tried to write a small bash code but its throwing errors.
Kindly... (13 Replies)
Discussion started by: biochemist
13 Replies
LEARN ABOUT DEBIAN
io::wrap
IO::Wrap(3pm) User Contributed Perl Documentation IO::Wrap(3pm)
NAME
IO::Wrap - wrap raw filehandles in IO::Handle interface
SYNOPSIS
use IO::Wrap;
### Do stuff with any kind of filehandle (including a bare globref), or
### any kind of blessed object that responds to a print() message.
###
sub do_stuff {
my $fh = shift;
### At this point, we have no idea what the user gave us...
### a globref? a FileHandle? a scalar filehandle name?
$fh = wraphandle($fh);
### At this point, we know we have an IO::Handle-like object!
$fh->print("Hey there!");
...
}
DESCRIPTION
Let's say you want to write some code which does I/O, but you don't want to force the caller to provide you with a FileHandle or IO::Handle
object. You want them to be able to say:
do_stuff(*STDOUT);
do_stuff('STDERR');
do_stuff($some_FileHandle_object);
do_stuff($some_IO_Handle_object);
And even:
do_stuff($any_object_with_a_print_method);
Sure, one way to do it is to force the caller to use tiehandle(). But that puts the burden on them. Another way to do it is to use
IO::Wrap, which provides you with the following functions:
wraphandle SCALAR
This function will take a single argument, and "wrap" it based on what it seems to be...
o A raw scalar filehandle name, like "STDOUT" or "Class::HANDLE". In this case, the filehandle name is wrapped in an IO::Wrap
object, which is returned.
o A raw filehandle glob, like "*STDOUT". In this case, the filehandle glob is wrapped in an IO::Wrap object, which is returned.
o A blessed FileHandle object. In this case, the FileHandle is wrapped in an IO::Wrap object if and only if your FileHandle class
does not support the "read()" method.
o Any other kind of blessed object, which is assumed to be already conformant to the IO::Handle interface. In this case, you just
get back that object.
If you get back an IO::Wrap object, it will obey a basic subset of the IO:: interface. That is, the following methods (note: I said
methods, not named operators) should work on the thing you get back:
close
getline
getlines
print ARGS...
read BUFFER,NBYTES
seek POS,WHENCE
tell
NOTES
Clearly, when wrapping a raw external filehandle (like *STDOUT), I didn't want to close the file descriptor when the "wrapper" object is
destroyed... since the user might not appreciate that! Hence, there's no DESTROY method in this class.
When wrapping a FileHandle object, however, I believe that Perl will invoke the FileHandle::DESTROY when the last reference goes away, so
in that case, the filehandle is closed if the wrapped FileHandle really was the last reference to it.
WARNINGS
This module does not allow you to wrap filehandle names which are given as strings that lack the package they were opened in. That is, if a
user opens FOO in package Foo, they must pass it to you either as "*FOO" or as "Foo::FOO". However, "STDIN" and friends will work just
fine.
VERSION
$Id: Wrap.pm,v 1.2 2005/02/10 21:21:53 dfs Exp $
AUTHOR
Primary Maintainer
David F. Skoll (dfs@roaringpenguin.com).
Original Author
Eryq (eryq@zeegee.com). President, ZeeGee Software Inc (http://www.zeegee.com).
perl v5.12.4 2011-09-18 IO::Wrap(3pm)