Visit Our UNIX and Linux User Community

How to call a shell script from a perl module which uses Filehandle to login

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to call a shell script from a perl module which uses Filehandle to login
# 1  
Old 01-28-2010
Java How to call a shell script from a perl module which uses Filehandle to login

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
# 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
= "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....

Last edited by pludi; 01-28-2010 at 04:50 AM.. Reason: code tags, please...
# 2  
Old 01-28-2010
You have pasted a 100 line of code and have asked people to figure out the entire without explaining why you want to do this and where in code you are doing this.


# 3  
Old 01-28-2010
How to call a shell script from a perl module which uses Filehandle to login

Sry mate I saw some earlier posts dated back to year 2005 so i thought System("") would not work any ways thanx a lot will try it.

Previous Thread | Next Thread
Test Your Knowledge in Computers #38
Difficulty: Easy
The standard port number for SMTP applications is 25.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

perl FileHandle Closure during after unlock

Hi we have one function which is used to append data the file in exclusive lock mode in aperl script. This script is executed by multiple threads at the same time. accessing the same file.this script runs throught the day. sometimes the file2.txt size is getting reduced. for eg from 10 M... (1 Reply)
Discussion started by: Shahul
1 Replies

2. Shell Programming and Scripting

Login using perl LWP module

Hi, Could some one tell me how to login to any web site and get that page using perl LWP. I heard that we can login to the site using LWP. I dont want to use WWW:Mechanize as I dont have that module installed on the server. Appreciate your early response. Thanks... (8 Replies)
Discussion started by: Anjan1
8 Replies

3. Shell Programming and Scripting

shell script to call perl script problems

Ok, don't ask me why, but all calls to perl must be called by a shell script. Its really not ideal, but its what I have to work with. Calling it isnt the issue, its passing in the arguments. I have about 1000 perl scripts to call by a shell script. Right now, I'm executing the shell script... (3 Replies)
Discussion started by: regexnub
3 Replies

4. Shell Programming and Scripting

login in wincvs thorugh shell or perl script

Hi , I am trying to write a script which does the wincvs login and does some checkout operations. When i do it from command prompt with command wincvs -d :pserver:username@server:/cvs/repository it pops up a cvs window and i can do some operations there. I wanted to automate this through... (1 Reply)
Discussion started by: namishtiwari
1 Replies

5. Shell Programming and Scripting

call shell script from perl cgi script problem

hi,, i have perl scipt with line : system('./ $t $d $m'); in shell scipt i have the line: echo $1 its not printing value of $t that i hav passed..y is it so..i am running it from apache web server (2 Replies)
Discussion started by: raksha.s
2 Replies

6. Shell Programming and Scripting

Call a perl script inside a shell script

Hi all, I have the following snippet of code.. #!/bin/sh echo "run perl script............" #Run the verification script perl bill_ver echo " perl script completed....." echo "rename files......" #Remove from all file in the directories test, test1, test2, test3 for f in... (3 Replies)
Discussion started by: chriss_58
3 Replies

7. Shell Programming and Scripting

Shell/perl script to connect to different servers in single login in teradata

Hi, I want to write a shell script to compare two tables in teradata.these tables are present on different servers. I want to connect to both servers in single login in order to fetch and compare the data in one go. Thanks (1 Reply)
Discussion started by: monika
1 Replies

8. Shell Programming and Scripting

Perl: Opening a filehandle but not getting anything back from it

I have two perl functions defined, both run a set of shell commands on some somplied data and return hashs of the resulting parsed output from these shell commands. One works, one doesn't and I can't seem to see why. It's driving me insane :mad: The working one: sub getcellstatus { ... (8 Replies)
Discussion started by: Smiling Dragon
8 Replies

9. Shell Programming and Scripting

How to call a perl script from a shell script

I have a perl script, which needs arguments from command line like arg1 arg2 arg3 how can i call it from a shell script (2 Replies)
Discussion started by: anumkoshy
2 Replies

10. Shell Programming and Scripting

Correct Syntax For Calling Shell Script in Perl Module

Problem: I have a shell script that will be called by a Perl module that will connect to a db and delete rows. The Perl module will be called by CRON. I am using a Perl module to call a shell script because I need to get the db connection from Perl. Here is the Perl pseudocode: ... (4 Replies)
Discussion started by: mh53j_fe
4 Replies

Featured Tech Videos