Hi Guru's,
Pardon me for the breach of rules.....
I have very little knowledge about Shell Programming and Scripting hope you guys help me out of this troble
I have very little time hence could not find the right way to direct my queries.
coming to the problem
I need to call a shell script from a perl module which uses Filehandle to login...
this is how the Code looks like
# package SFTP PUT_APEX
package SFTP_PUT_APEX;
# package SFTP PUT_APEX
package SFTP_PUT_APEX;
# Use the following Perl SFTP Libraries
use Net::SFTP::Foreign;
use File::Copy;
# Set generic components lib path
use lib ("$ENV{'BATCH_CODE'}/generic_components");
# Include the ERROR_FILE component
use ERROR_FILE;
# sub FTP PUT batch component
sub sftp_put {
# Get the parameters passed from the Batch Holder
my ($date_time, $CONFIG_FILE_PATH, $SFTP_RENAME_APEX, $FILENAME) = @_;
# Open the configuration text file in which all the environment variables are stored
open (CONFIG, $CONFIG_FILE_PATH) or return CallingError(ERROR_FILE::errorMethod($date_time,$CONFIG_FILE_PATH, $BATCH_ID = "NO_ID", $ERROR_COMPONENT =
" $hash{'ERROR_COMP_FTPPUT'}", $ERROR_STATUS = "N", $ERROR_CODE = "FEAPP6000", $ERROR_SHORT = "Could not Open file", $ERROR_DESC = "Could not open the confi
guration file located: $CONFIG_FILE_PATH", $SEVERITY = "10"));
# Put all the data in the configuration file into an array
@data = <CONFIG>;
# Loop through each line of the file that holds the variables
foreach $var_line (@data) {
# If the current line in the data is a variable
if( $var_line =~ /(.+)\s+(.+)/ ) {
# Store in hash table
$hash{ $1 } = $2;
}
}
# Open the file where the username is stored
open(FILEHANDLE, "$ENV{'BATCH_HOME'}/$hash{'USERPASSAPEX'}") or return CallingError(ERROR_FILE::errorMethod($date_time, $CONFIG_FILE_PATH, $BATCH_ID
="NO_ID", $ERROR_COMPONENT = "$hash{'ERROR_COMP_FTPPUT'}", $ERROR_STATUS = "N", $ERROR_CODE = "FEAPP6000", $ERROR_SHORT = "Could not Open file", $ERROR_DESC
= "Could not open the username/password file located: $hash{'USERPASSAPEX'}", $SEVERITY = "10"));
# Loads all the lines of the username/password file into an array
@no_of_lines = <FILEHANDLE>;
# If there file is not NULL
if (@no_of_lines ne NULL) {
# For each line in the array
foreach $no_of_lines(@no_of_lines) {
# Assign the current line to a variable
$first_line = $no_of_lines;
# Get the first character of the line and assign it to a variable
($checkhash) = ($first_line =~ /^(\C)/);
# If there is not a hash in front of the current line, this must contain the username and password
if ($checkhash ne '#') {
# Gets the username from the file
($username) = ($first_line =~ /^(\S+),/);
print $username;
print "The User Name is Printed above";
# Capture an error if the username is blank
if ($username eq NULL) {
# Call error handler and terminate the FTP Put component
CallingError(ERROR_FILE::errorMethod($date_time, $CONFIG_FILE_PATH, $BATCH_ID= "NO_ID", $ERROR_COMPONENT = "$hash{'ERROR_COMP
_FTPPUT'}", $ERROR_STATUS = "N", $ERROR_CODE = "FEAPP6008", $ERROR_SHORT = "Variable is NULL", $ERROR_DESC = "The SFTP username is NULL", $SEVERITY = "10"));
}
# Set the local directory path where the data files will be stored
chdir ("$ENV{'BATCH_HOME'}/$hash{'DATA_FILE_APEX'}");
I know it is outrageous to ask for such a request but i would be very thankful if you can help me out....