Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
This subroutine needs to check if there was a file name given on the command line. If so, return that. Otherwise get a file name from the user and return it if the file exists. If it does not exist stay in an input loop until the user enters the name of a file that does exist.
2. Relevant commands, code, scripts, algorithms:
Variables I want to use are $fileName for any user input and the default variable $_ or <> for if the filename is included in the command line.
3. The attempts at a solution (include all code and scripts):
How do I define and call a subroutine in a ksh script (or any shell)? I'm writing a script that uses a lot of the same code over and over and I don't want to waste time/space.
Thanks,
Chuck (2 Replies)
Hi:
How do I pass a hash table down to a subroutine along with some other variables?
For example, I have say a subroutine play_with_hash:
sub play_with_hash
{
my( $var1, $var2, %my_hash ) = @_;
#do stuff with %my_hash
...........
}
Then I want to call the subroutine... (1 Reply)
Hi ,
This script working for fine if pass script-name.sh Jul/10/2007 ,I want to pass 20070710(yyyymmdd) .Please any help it should be appereciated.
use Time::Local;
my $d = $ARGV;
my $t = $ARGV;
my $m = "";
@d = split /\//, $d;
@t = split /:/, $t;
if ( $d eq "Jan" ) { $m = 0 }... (7 Replies)
I'm maintaining a variety of programs (mostly in Perl) I didn't build, and the perllib is huge on the server. When I run across a user-defined subroutine it takes me at least an hour to look through all the logical places, and sometimes I still can't find the definition.
Is there an easy way to... (2 Replies)
How to do I get the return code of a subroutine in a perl module if invoke the subroutine as standalone,
I have an module say TestExit.pm and in that i have a subroutine say myTest() which is returns 12, if i were to call the subroutine from
command line like
CASE:1 ( Without an explict... (2 Replies)
How can i print the output of a perl script on a unix console and redirect the same in a log file under same directory simultaneously ?
Like in Shell script, we use tee, is there anything in Perl or any other option ? (2 Replies)
i want to call subroutines in perl like:
sub temp
{ ---- some code ----- }
temp(-switchName, value1, --switchName2, value2)
Like i know getoptions::Long is there for command line switches type arguments. So i want to know for subroutine type arguments. (1 Reply)
#!/usr/bin/bash
sub1 () {
for ((i=0;i<10;i++))
do
export a=$i;
echo "value of a is $a";
sleep 1
done
}
sub1 &
sub2 () {
for ((j=0;j<10;j++))
do
echo "value of a is $a";
sleep 1
done
} (5 Replies)
HI Folks -
Again, I'm very sorry for the amateur post. I'm reletively new to shell scripting so please bear with me.
I have a script that execute another script which stops a particular set of services for my application. IF the execution is successful, I want to check for any hung ESSSVR... (4 Replies)
I have reviewed many examples on-line about running another process (either PERL or shell command or a program), but do not find any usefull for my needs way. (Reviewed and not useful the system(), 'back ticks', exec() and open())
I would like to run another PERL-script from first one, not... (1 Reply)