I have oracle VM in my virtualbox and from host OS I want to be able to run a shell script which would: 1. put an .sql script into VM 2. run the sqlcl and the .sql script on a VM
When I run oracle sqlcl from my host machine it throws an error - unknown host. Basically when I run sqlcl in VM machine bash it works, when I run it in a script that ssh(es) to the VM it doesn't work.
I'm sure I'm missing something very fundamental about users/ssh/sessions in linux. It would be great if somebody could point out what I should learn more about too.
my bash script:
#!/bin/bash
sshpass -p 'oracle' sftp -P 2200 oracle@127.0.0.1:/myscripts/ << END_OF_SFTP
put foo
pwd
bye
END_OF_SFTP
sshpass -p 'oracle' ssh -p 2200 oracle@127.0.0.1 << END_OF_SSH
who
cd /myscripts/
./runscript hello_world.sql
END_OF_SSH
runscript is a script I put on my VM to run provided .sql scripts - this is how it looks:
#!/bin/bash
/u01/userhome/oracle/sqlcl/bin/sql hr/oracle @/myscripts/$1
output I get:
Connected to 127.0.0.1.
Changing to: /myscripts/
sftp> put foo
Uploading foo to /myscripts/foo
sftp> pwd
Remote working directory: /myscripts
sftp> bye
#I have no idea what below lines mean :(
#running sqlcl
Pseudo-terminal will not be allocated because stdin is not a terminal.
oracle :0 2019-08-03 06:26 (:0)
oracle pts/0 2019-08-03 06:28 (:0)
SQLcl: Release 19.1 Production on Sat Aug 03 07:19:12 2019
Copyright (c) 1982, 2019, Oracle. All rights reserved.
USER = hr
URL = jdbc:oracle:thin:@ORCL
Error Message = IO Error: Unknown host specified
USER = hr
URL = jdbc:oracle:thin:@ORCL:1521/ORCL
Error Message = IO Error: Unknown host specified