Hi All,
I want to run a bash script using perl. But they are in the different dir.
#! /usr/bin/perl -w
use strict;
my $root=`pwd`;
chomp($root);
my $cmd=".$root/testdir/ft_623.sh 3 4 5 6 7";
print $cmd;
my @line=`$cmd`;
foreach (@line){
print $_;
}
ft_623.sh
#!/bin/bash
funct(){
ntad=$1
smad=$2
rtad=$3
domain=$4
dns=$5
echo "ntad is $ntad"
echo "smad is $smad"
echo "rtad is $rtad"
echo "domain is $domain"
echo "dns are $dns"
}
if [ $# -ge 5 ];then
funct $@
else
echo "The number of Arguments is less then 5."
echo $#
fi
exit 0
when i run it,
it says
bash-3.00# ls
bin config etc expected lib log runtest.pl testdir testscripts tmp
bash-3.00# pwd
/eweiquu/ocsta
bash-3.00# ./runtest.pl
./eweiquu/ocsta/testdir/ft_623.sh 3 4 5 6 7Can't exec "./eweiquu/ocsta/testdir/ft_623.sh": No such file or directory at ./runtest.pl line 8.
bash-3.00# cd runtest.pl
bash: cd: runtest.pl: Not a directory
bash-3.00# cd testdir/
bash-3.00# ls
ft_621.sh ft_623.sh
bash-3.00# pwd
/eweiquu/ocsta/testdir
and if I modify the perl cmd
my $cmd="bash $root/testdir/ft_623.sh 3 4 5 6 7";
it works properly
but sometimes the script is not written by the bash
I just want to use dot(.) to run the script
what can i do?
BRs
Damon sine
---------- Post updated at 01:02 PM ---------- Previous update was at 12:32 PM ----------
and if I write like this
my $cmd=". $root/testdir/ft_623.sh 3 4 5 6 7";
it says
bash-3.00# ./runtest.pl
. /eweiquu/ocsta/testdir/ft_623.sh 3 4 5 6 7\nThe number of Arguments is less then 5.
0