Run perl script from Unix script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Run perl script from Unix script
# 1  
Old 09-02-2011
Run perl script from Unix script

Hello Guys

I have to run a perl script from unix one

The reason for this is I have to connect to remote server and then execute the perl script.
In unix script I am able to connect to remote server without any password via ssh

Code:
 
ssh -o 'PasswordAuthentication yes' -o 'PreferredAuthentications publickey' -i $HOME/.ssh/id_dsa

I dont know the eqivalent code in perl

so I am trying via unix script to connect the remote server and execute the perl script

My code is below

Code:
 
#!/usr/bin/ksh
ssh -o 'PasswordAuthentication yes' -o 'PreferredAuthentications publickey' -i $HOME/.ssh/id_dsa us320 <<EOF;
perl Balancing.pl m_SBD_GRD_0277_GP_VTL_PORT_CNTR_to_WRHS_STG;
if [$? = 0]
then
echo executed successfully;
else 
exit 
fi
EOF

Its result fine but getting warning like
stty: : No such device or address

So please let me know the equivalent remote connection in perl or how to avoid this warning
# 2  
Old 09-02-2011
Code:
ssh -o 'PasswordAuthentication yes' -o 'PreferredAuthentications publickey' -i $HOME/.ssh/id_dsa "perl /Path/of/the/Perl/file/Balancing.pl m_SBD_GRD_0277_GP_VTL_PORT_CNTR_to_WRHS_STG"

This User Gave Thanks to itkamaraj For This Post:
# 3  
Old 09-02-2011
Or use the Net::SSH module to make the connection (requires publickey be set up, but you have that.)
This User Gave Thanks to Skrynesaver For This Post:
# 4  
Old 09-02-2011
Thanks a lot to both of you but when I run

ssh -o 'PasswordAuthentication yes' -o 'PreferredAuthentications publickey' -i $HOME/.ssh/id_dsa us320 "perl Balancing.pl $1"

its giving
Code:
sqlplus not found

But the same when I run like this

Code:
 
ssh -o 'PasswordAuthentication yes' -o 'PreferredAuthentications publickey' -i $HOME/.ssh/id_dsa us320 <<EOF;
echo $1
perl Balancing.pl $1

its working fine

Please let me know how its so
# 5  
Old 09-02-2011
In the first case, the Perl program is unable to "see" the environment variables of the remote server; in the second case it is.

tyler_durden
This User Gave Thanks to durden_tyler For This Post:
# 6  
Old 09-06-2011
Thanks Tyler ..
So is there any way to resolve the same?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script run in a case statement call to run a php file, also Perl

Linux System having all Perl, Python, PHP (and Ruby) installed From a Shell script, can call a Perl, Python, PHP (or Ruby ?) file eg eg a Shell script run in a case statement call to run a php file, also Perl or/and Python file??? Like #!/usr/bin/bash .... .... case $INPUT_STRING... (1 Reply)
Discussion started by: hoyanet
1 Replies

2. UNIX for Dummies Questions & Answers

Perl Script:how to find how many parameters are required to run the script

How to find how many parameters are required to run a Perl script? (1 Reply)
Discussion started by: Lakshman_Gupta
1 Replies

3. Shell Programming and Scripting

Run shell script on different machine using perl script

I want to execute my shell script on remote machine using SSH in perl script. Please help me with syntax. (2 Replies)
Discussion started by: james1988
2 Replies

4. Shell Programming and Scripting

Run few perl script in CMD using script

Hi, I have few PERL script which I have to run in CMD. I want to create a new script which will take care of running all these scripts in CMD.:confused: can any one suggest which script will be appropriate to solve my problem. Thanks in advance. (1 Reply)
Discussion started by: arup1980
1 Replies

5. Shell Programming and Scripting

Perl script run a bash script

Hi All, I think the processing of this is much more complex, so I will explain the whole process by codes. First,I wrote a expect script named bsim.exp as follows: #! /usr/local/bin/expect set command set name eval spawn $command switch -exact $command { "bash expecttest.sh" { ... (2 Replies)
Discussion started by: Damon sine
2 Replies

6. Shell Programming and Scripting

trying to run this script from unix but the script is not successfull

Hi I am trying to run the below unix script in informatica comamnd task the script is in placed in the path (this script checks if the files are present in other server ) ------------------------------------------------------------------... (1 Reply)
Discussion started by: laxmi131
1 Replies

7. Shell Programming and Scripting

perl script to check if empty files are created and delete them and run a shell script

I have a local linux machine in which the files are dumped by a remote ubuntu server. If the process in remote server has any problem then empty files are created in local machine. Is there any way using perl script to check if the empty files are being created and delete them and then run a shell... (2 Replies)
Discussion started by: hussa1n
2 Replies

8. Shell Programming and Scripting

Can you run a unix script from a perl program

Hi all i have a unix script reformatter.sh i have a process whereby this script reformats a file before a perl program is used to update it i am having a little problem automating the entire process . is there a way whereby i can call the unix script from the perl program ? (12 Replies)
Discussion started by: dwightja24
12 Replies

9. Shell Programming and Scripting

check in unix shell script so that no one is able to run the script manually

I want to create an automated script which is called by another maually executed script. The condition is that the no one should be able to manually execute the automated script. The automated script can be on the same machine or it can be on a remote machine. Can any one suggest a check in the... (1 Reply)
Discussion started by: adi_bang76
1 Replies

10. Shell Programming and Scripting

Perl: Run perl script in the current process

I have a question regarding running perl in the current process. I shall demonstrate with an example. Look at this. sh-2.05b$ pwd /tmp sh-2.05b$ cat test.sh #! /bin/sh cd /etc sh-2.05b$ ./test.sh sh-2.05b$ pwd /tmp sh-2.05b$ . ./test.sh sh-2.05b$ pwd /etc sh-2.05b$ So... (10 Replies)
Discussion started by: vino
10 Replies
Login or Register to Ask a Question