Home » Open Source » Programming Interfaces » Unable to change Oracle SID with Net::SSH::Perl (All)
Unable to change Oracle SID with Net::SSH::Perl [message #429421] Tue, 03 November 2009 11:53 Go to next message
fairgame
Messages: 29
Registered: October 2008
Junior Member
Hi,

I am running a Perl code from Linux machine and doing SSH to Windows machine.

When I am trying to change SID with this command, it's not working. The SID does not change and it keeps the default SID.

#-- set up a new connection
	my $ssh = Net::SSH::Perl->new($host);
#-- authenticate
	$ssh->login($user, $password);
#-- execute the command
        $ssh->cmd('SET ORACLE_SID=testsid');
Re: Unable to change Oracle SID with Net::SSH::Perl [message #429423 is a reply to message #429421] Tue, 03 November 2009 12:15 Go to previous messageGo to next message
Michel Cadot
Messages: 63812
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Does it do it for other variables?

Regards
Michel
Re: Unable to change Oracle SID with Net::SSH::Perl [message #429424 is a reply to message #429423] Tue, 03 November 2009 12:18 Go to previous messageGo to next message
fairgame
Messages: 29
Registered: October 2008
Junior Member
Yes my next command is to run one script which it does perfectly.

$command = 'sqlplus scott/tiger @testscript.sql'
$ssh->cmd($command);

Re: Unable to change Oracle SID with Net::SSH::Perl [message #429425 is a reply to message #429424] Tue, 03 November 2009 13:05 Go to previous messageGo to next message
ThomasG
Messages: 3186
Registered: April 2005
Location: Heilbronn, Germany
Senior Member
Does the script also print the output of the commands? (If Net::SSH is anything like Net::FTP, maybe there is an additional "Debug" parameter that can be set in the connect command)

If so, try an additional just "set" command, to see how the variables are actually set.


Re: Unable to change Oracle SID with Net::SSH::Perl [message #429433 is a reply to message #429425] Tue, 03 November 2009 15:24 Go to previous messageGo to next message
fairgame
Messages: 29
Registered: October 2008
Junior Member
@Thomas Yes, the script gives the standard output.

Now, as you said I tried to SET some variable and it didn't work.

my $cmd1 = 'set TEST=Success && echo %TEST%';

my($stdout, $stderr, $exit) = $ssh->cmd($cmd1);

print "$stdout, $stderr, $exit \n";


And my out put is
%TEST%, ,0
Re: Unable to change Oracle SID with Net::SSH::Perl [message #429444 is a reply to message #429421] Tue, 03 November 2009 20:14 Go to previous messageGo to next message
fairgame
Messages: 29
Registered: October 2008
Junior Member
I figured it out,

each cmd will create a different shell/session, The possible solution is

my($stdout, $stderr, $exit) = $ssh->cmd(<<SHELL);
set ORACLE_SID = testsid;
sqlplus "/as sysdba" @test.sql;
SHELL


But this is working only for Unix not Windows.
Re: Unable to change Oracle SID with Net::SSH::Perl [message #429512 is a reply to message #429444] Wed, 04 November 2009 05:13 Go to previous message
ThomasG
Messages: 3186
Registered: April 2005
Location: Heilbronn, Germany
Senior Member
Hmmmmm... What's more even the "Windows Way" of piping commands doesn't seem to work, without involving an SSH connection.

If you run
(
echo This is an test > test.out
set VAR=yo           >>test.out
echo %VAR%           >>test.out  
) | cmd.exe /c


Directly under Windows, that also doesn't set the variable:

C:\>(
Mehr? echo This an test > test.out
Mehr? set VAR=yo        >>test.out
Mehr? echo %VAR%        >>test.out
Mehr? ) | cmd.exe /c

U:\>type test.out
This an test
%VAR%

C:\>


The other workaround I could imagine would be to put everything in a batch file that you can then call with the parameters you want in one command line.

Previous Topic: ODBC log shows ORA error even though the procedure runs fine on the backend.
Next Topic: DBD::Oracle install problem on 64-bit RHEL51
Goto Forum:
  


Current Time: Fri Sep 30 07:20:12 CDT 2016

Total time taken to generate the page: 0.07998 seconds