Need Help with Perl Scripting Issue.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need Help with Perl Scripting Issue.
# 15  
Old 12-11-2008
Okay on further investigation it looks like the following command is not being executed:


Smiliepen(SMP, "/usr/local/bin/sshpass -p test ssh test.com -l root /usr/contrib/bin/serverinfor -b |") || die "Failed: $!\n";


Hence that is why I do not see any output on the browser? Is there any other way of calling this function?
# 16  
Old 12-12-2008
Quote:
Originally Posted by manik112
Okay on further investigation it looks like the following command is not being executed:


Smiliepen(SMP, "/usr/local/bin/sshpass -p test ssh test.com -l root /usr/contrib/bin/serverinfor -b |") || die "Failed: $!\n";


Hence that is why I do not see any output on the browser? Is there any other way of calling this function?
What is the error message received or logged ( using $! )? That should be a hint
# 17  
Old 12-12-2008
Well the issue is that am not getting any error messages.......
# 18  
Old 12-12-2008
Quote:
Originally Posted by manik112
No nothing is written into the error log and that is why am so confused. Here is the output of the access log:
10.10.10.10 - - [11/Dec/2008:19:26:37 +0000] "GET /icons/page-background.png HTTP/1.1" 304 - "http://10.10..10.1/cgi-bin/test2.pl" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648)"
You have not provided the correct log line. This line is for the image 'page-background.png' indicates the URL is being redirected (to the script??). The redirection is either not completing (and thus no long line is generated) or the log line appears later.

Try simply including an "exit(0);" after your initial "print Content-type" line. You should then see a line in the logs with status 200. Keep moving the "exit()" line and doing a refresh until the log line is no longer 200 (or does not appear).
# 19  
Old 12-12-2008
Okay tried the suggestion and here are the logs entries.

10.10.10.10 - - [12/Dec/2008:20:17:13 +0000] "GET /favicon.ico HTTP/1.1" 404 287 "http://10.10.10.1/cgi-bin/test.pl" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_5; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1"
10.10.10.10 - - [12/Dec/2008:20:17:50 +0000] "GET /cgi-bin/test.pl HTTP/1.1" 200 283 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_5; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1"
10.10.10.10 - - [12/Dec/2008:20:17:50 +0000] "GET /favicon.ico HTTP/1.1" 404 287 "http://10.10.10.1/cgi-bin/test.pl" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_5; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1"
10.10.10.10- - [12/Dec/2008:20:17:50 +0000] "GET /icons/test.gif HTTP/1.1" 200 4110 "http://10.10.10.1/cgi-bin/test.pl" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_5; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1"
10.10.10.10 - - [12/Dec/2008:20:17:50 +0000] "GET /icons/page-background.png HTTP/1.1" 200 17055 "http://10.10.10.1/cgi-bin/test.pl" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_5; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1"
# 20  
Old 12-12-2008
I tried different perl package to just open a ssh shell to one of the server and executed it via the url and any ideas how to fix this issue? Since if this works, then I can replace my above script with this approach:

#!/usr/bin/perl -w

use warnings;
use strict;
use Socket;
#use Net::SSH::Perl;
use Net::OpenSSH;


my $ssh = Net::OpenSSH->new('root:root@10.10.10.1');
$ssh->error and die "Can't ssh : " . $ssh->error;

my $output = $ssh->capture( "ls -la");
$ssh->error and
warn "operation didn't complete successfully: ". $ssh->error;
print $output;


The Error when executed from URL is:
[Fri Dec 12 20:26:52 2008] [error] [client 10.10.10.10] Can't ssh : unable to stablish master ssh connection: the authenticity of the target host can't be established, try loging manually first at /var/www/cgi-bin/test2.pl line 20.
[Fri Dec 12 20:26:52 2008] [error] [client 10.10.10.10] Premature end of script headers: test2.pl



NOTE: The command works fine when executed from command line.......
# 21  
Old 12-12-2008
the one in red is the one you want to watch for. In the example you provided, the code is 200, so your request worked.

Quote:
Originally Posted by manik112
Code:
10.10.10.10 - - [12/Dec/2008:20:17:13 +0000] "GET /favicon.ico HTTP/1.1" 404 287 "http://10.10.10.1/cgi-bin/test.pl" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_5; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1"
10.10.10.10 - - [12/Dec/2008:20:17:50 +0000] "GET /cgi-bin/test.pl HTTP/1.1" 200 283 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_5; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1"
10.10.10.10 - - [12/Dec/2008:20:17:50 +0000] "GET /favicon.ico HTTP/1.1" 404 287 "http://10.10.10.1/cgi-bin/test.pl" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_5; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1"
10.10.10.10- - [12/Dec/2008:20:17:50 +0000] "GET /icons/test.gif HTTP/1.1" 200 4110 "http://10.10.10.1/cgi-bin/test.pl" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_5; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1"
10.10.10.10 - - [12/Dec/2008:20:17:50 +0000] "GET /icons/page-background.png HTTP/1.1" 200 17055 "http://10.10.10.1/cgi-bin/test.pl" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_5; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1"

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Scripting issue

I am having a problem. which I have described below>> I have to run a script with the format : <File_name><Start_date><End_date> abcd.sh 19-JAN-2015 01-May-2014 problem is I need to compare these two dates and throw an error as start date must be less than or equal to end date. But... (13 Replies)
Discussion started by: Chandan_Bose
13 Replies

2. Homework & Coursework Questions

Perl Scripting issue - homework

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: Here is the problem: Lesson 13 OBJ1: OST Class online. Write a script called obj13-1.pl and a library... (2 Replies)
Discussion started by: valhalla
2 Replies

3. Web Development

Perl scripting or shell scripting?

i am going to study any one of the scripting languages mentioned above(shell 0r perl scripting) . Which is having more scope for a fresher? (1 Reply)
Discussion started by: Anna Hussie
1 Replies

4. What is on Your Mind?

Shell Scripting vs Perl scripting

Gents, I have been working in a Solaris/Unix environment for about 9 months. I took some linux classses online before getting the job. But, I am not very good at scripting. I want to learn how to script. Do you think that I should start with Shell scripting or Perl? I wanted to continue with... (2 Replies)
Discussion started by: Pouchie1
2 Replies

5. Shell Programming and Scripting

Scripting Issue

needing this script to shut down 1 IceS and start up another, close the 2nd one after 12 seconds and then reboot. here is what i have so far #!/bin/bash ShutDown() { echo "Shutdown in progress." wall <<ENDOFWALL CI Shutdown has been intiated!!!! Shutdown will occur in 30 seconds...... (1 Reply)
Discussion started by: Zaine
1 Replies

6. What is on Your Mind?

Shell scripting vs Perl scripting

Hi all, I would like to start developping some good scripting skills. Do you think it would be best to start with shell scripting or Perl? I already got a fundation, really basics, in perl. but I am wondering what would be best to be good at first. Can you please help me determine which one to... (14 Replies)
Discussion started by: Pouchie1
14 Replies

7. Shell Programming and Scripting

Scripting Issue

I am having an issue with a script that I created today, my first attempt at this, and was wondering if anyone can give me insight to what changes need to be made. Below is a copy of the script that I have written. WEe are trying to monitor whether or not a services is running. I do have a cron... (1 Reply)
Discussion started by: lsudubee
1 Replies

8. Shell Programming and Scripting

Call Shell scripting from Perl Scripting.

Hi How to call a shell scripting through a Perl scripting? Actually I need some value from Shell scripting and passes in the Perl scripting. So how can i do this? (2 Replies)
Discussion started by: anupdas
2 Replies

9. Shell Programming and Scripting

Scripting issue

Hello, I have an ASCII file (many files of the same format, but different dates and numbers) in the format like below: 2008.01.02,08:00,1.46520,1.46520,1.46410,1.46440,70 2008.01.02,08:05,1.46450,1.46560,1.46440,1.46540,79 2008.01.02,08:10,1.46530,1.46540,1.46490,1.46500,46... (8 Replies)
Discussion started by: chief2000
8 Replies

10. Shell Programming and Scripting

IP-Scripting Issue

Hi Guys, I am quite new to Shell Scripting... I need ur help.. This is very urgent. The thing is like, I need to match a IP address (ex 192.168.200.56) i.e, xxx.xxx.xxx.xx inside a KSH script,but if we enter in different format other than the specified format (ex jjj.ksj., 1.0...), it should... (3 Replies)
Discussion started by: mraghunandanan
3 Replies
Login or Register to Ask a Question