Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 4th, 2012, 11:39 AM
Bindo Bindo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2011
Posts: 48 Bindo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 41 m 26 sec
Reputation Power: 2
Perl remote commands

Greetings Mr Fish/Laurent and All other good gentlemen

Im trying to write a script where I need to run some commands on a remote server. Following is the description
--script is being run from the host A
--no CPAN modules are allowed to install.

1. ssh in to the host B which is an oracle box (public key ssh is enabled & )
2. from host B, I need to be able to connect to the DB as sysadmin (sqlplus "/ as sysdba") and run a command probably ("select * from tab;") and assign it in to a variable.

Could someone please help me? I'd really appreciate it.

Many thanks in advance
/Bindo

Reply With Quote
  #2  
Old November 4th, 2012, 11:42 AM
FishMonger FishMonger is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2009
Posts: 1,652 FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 2 Days 6 h 21 sec
Reputation Power: 1170
Quote:
--no CPAN modules are allowed to install.


Why not?

Reply With Quote
  #3  
Old November 4th, 2012, 11:56 AM
Bindo Bindo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2011
Posts: 48 Bindo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 41 m 26 sec
Reputation Power: 2
It is just a stupid policy that is in my work place Sir.

Reply With Quote
  #4  
Old November 4th, 2012, 12:04 PM
Laurent_R Laurent_R is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jun 2012
Posts: 511 Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 4 Days 19 h 58 m 22 sec
Reputation Power: 405
If you can't use CPAN modules, you will probably need to issue a series of Unix commands to the system, using the system command or the backticks.

I haven't tried it, but I think it should work (I have done relatively similar things in shell scripts, but quite some time ago, I don't remember the details).

Reply With Quote
  #5  
Old November 4th, 2012, 12:13 PM
FishMonger FishMonger is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2009
Posts: 1,652 FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 2 Days 6 h 21 sec
Reputation Power: 1170
Then your employer doesn't have a clue about perl.

Can this task be done in Perl without the use of any modules? Yes it can.

Should it be written without the aide of modules? Absolutely not.

Without the use of modules, your script will boil down to a collection of system calls and with that in mind, you should write a shell script.

Reply With Quote
  #6  
Old November 4th, 2012, 12:43 PM
Bindo Bindo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2011
Posts: 48 Bindo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 41 m 26 sec
Reputation Power: 2
Quote:
Originally Posted by FishMonger
Then your employer doesn't have a clue about perl.

Can this task be done in Perl without the use of any modules? Yes it can.

Should it be written without the aide of modules? Absolutely not.

Without the use of modules, your script will boil down to a collection of system calls and with that in mind, you should write a shell script.



Thanks Mr Laurent. i tried the system command but I could only get to the host B via ssh. I have no clue as to how I should run sqlplus henceforth.

Thanks Mr Fish. I totally agree with you about the CPANs. I'll try a little more and see if I get lucky sir. Thanks anyways.

Reply With Quote
  #7  
Old November 4th, 2012, 01:59 PM
Laurent_R Laurent_R is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jun 2012
Posts: 511 Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 4 Days 19 h 58 m 22 sec
Reputation Power: 405
It really depends on the system and set-up on platform B. You may need to source the .profile (or something equivalent) before you can run the sqlplus command, so that the environment variables are correctly set-up.

It usually takes a bit of trying various things before succeeding to have it right.

Reply With Quote
  #8  
Old November 4th, 2012, 03:54 PM
testerV testerV is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2012
Posts: 65 testerV User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 35 m 42 sec
Reputation Power: 1
Hi Bindo,
I had the same problem at my work - nothing can be installed (including Perl modules) on any of the machines but then I learn how do do this manually (thanks to this website, Fish and Omega personally). Try it Dude, your life will become much easier.
Thanks, testerV

Reply With Quote
  #9  
Old November 5th, 2012, 12:13 PM
Axweildr's Avatar
Axweildr Axweildr is offline
'fie' on me, allege-dly
Click here for more information.
 
Join Date: Mar 2003
Location: in da kitchen ...
Posts: 12,874 Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)Axweildr User rank is General 81st Grade (Above 100000 Reputation Level)  Folding Points: 162285 Folding Title: Super Ultimate Folder - Level 1Folding Points: 162285 Folding Title: Super Ultimate Folder - Level 1Folding Points: 162285 Folding Title: Super Ultimate Folder - Level 1Folding Points: 162285 Folding Title: Super Ultimate Folder - Level 1Folding Points: 162285 Folding Title: Super Ultimate Folder - Level 1Folding Points: 162285 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 4 Months 2 Weeks 1 Day 20 h 28 m 56 sec
Reputation Power: 6421
Send a message via Google Talk to Axweildr
Orkut
First off, I'd prefer not advising people to violate their workplace policies, as it could result in disciplinary procedures being levied against them, or worse, dismissal

Sometimes it helps to think of policies as living documents which can be changed over time, with some controlling restraints, like logs of permitted policy breach, with management signoff, etc, etc

banking and other organisationsare completely anal about some of these policies and it's with good reason, as undocumented software changes in production environments are not something to be taken lightly

If they are rigid on this policy, then ask about their software release methodology/policy

HTH
__________________
--Ax
without exception, there is no rule ...
Handmade Irish Jewellery
Targeted Advertising Cookie Optout (TACO) extension for Firefox
The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones


09 F9 11 02
9D 74 E3 5B
D8 41 56 C5
63 56 88 C0
Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.
-- Jamie Zawinski
Detavil - the devil is in the detail, allegedly, and I use the term advisedly, allegedly ... oh, no, wait I did ...
BIT COINS ANYONE

Reply With Quote
  #10  
Old November 5th, 2012, 08:22 PM
spacebar208's Avatar
spacebar208 spacebar208 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2012
Location: spaceBAR Central
Posts: 191 spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level)spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level)spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level)spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level)spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level)spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Days 9 h 59 m 25 sec
Reputation Power: 41
Quote:
Originally Posted by Bindo
1. ssh in to the host B which is an oracle box (public key ssh is enabled & )
2. from host B, I need to be able to connect to the DB as sysadmin (sqlplus "/ as sysdba") and run a command probably ("select * from tab;") and assign it in to a variable.

This is a simple example of using ssh to run sqlplus on remote host and populate variable on local host which is what I believe you are trying to do:
Code:
#!/bin/ksh
# test_ssh.sh
ssh_results=`ssh user@host '. ./.profile;sqlplus -S user@instance/password <<ENDSQL
set linesize 500 heading off feedback off
select sysdate from dual;
ENDSQL'`
ssh_results=`print $ssh_results | tr -d '\f '`
print "$ssh_results"

$ test_ssh.sh
05-NOV-12

Reply With Quote
  #11  
Old November 14th, 2012, 06:22 AM
Bindo Bindo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2011
Posts: 48 Bindo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 41 m 26 sec
Reputation Power: 2
Im extremely sorry for late response.

Thank you very much all for good advices. I will get back to you soon once I try to put up something with your guidance. Thanks again good gentlemen.

Reply With Quote
  #12  
Old November 14th, 2012, 06:23 AM
Bindo Bindo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2011
Posts: 48 Bindo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 41 m 26 sec
Reputation Power: 2
Thank you very much Mr SpaceBar. This sounds quite promising.





Quote:
Originally Posted by spacebar208
This is a simple example of using ssh to run sqlplus on remote host and populate variable on local host which is what I believe you are trying to do:
Code:
#!/bin/ksh
# test_ssh.sh
ssh_results=`ssh user@host '. ./.profile;sqlplus -S user@instance/password <<ENDSQL
set linesize 500 heading off feedback off
select sysdate from dual;
ENDSQL'`
ssh_results=`print $ssh_results | tr -d '\f '`
print "$ssh_results"

$ test_ssh.sh
05-NOV-12

Reply With Quote
  #13  
Old November 15th, 2012, 05:58 AM
bolainmarsh4 bolainmarsh4 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 2 bolainmarsh4 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 43 sec
Reputation Power: 0
Depending on how your environment is set up, you can create processes on remote machines using WMI. Consult with your network / Windows administrator for the proper approach.

Short of finding out what mechanisms are available on Windows, we can't help you. This is not as much a Perl question but a question about your computing environment, and you are much closer to the people who know about that than we are.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Perl remote commands

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap