Move a file from one server to another server via plsql or shell - shell

I have a server with details :
server ip: 192.168.141.96 : 21 credentials: user: tss password: T#l30P#ss path: /home/ttt/
This is the server where a file is getting generated. I want to move this file to another server with credentials
Host: sftp://sftpabc.learn.com
User name: abc
Password: jQrE7wvg
Port: 22
import dir: upload/source
I am trying to use the following plsql script for this :
DECLARE
l_conn UTL_TCP.connection;
begin
l_conn := ftp.login('192.168.141.96', '21', 'tss', 'T#l30P#ss');
ftp.ascii(p_conn => l_conn);
FTP.GET(P_CONN => L_CONN,
P_FROM_FILE => 'filename_test.csv',
p_to_dir => 'DIR_INBOUND',
p_to_file => 'test_get.txt');
ftp.logout(l_conn);
END;
But this is not executing and no file is getting transgerred. Is there a shell script/plsql script for this ?

What do you mean by 'is not executing'. What is the error? A quick search shows that you may be using this site as reference for your code. If that is the case, did you make sure to compile the ftp.pks and ftp.pkb in your database?

Related

how i use plsql for sending csv file via FTP?

For the development of a solution of replication and consolidation between 2 schema oracle 10g distant. I want to use the FTP API (ftp.pks, ftp.pkb) to transfer a CSV file to an FTP server. when performing the dedicated procedure for that I have the error
ORA-31024: Parser initialization failed with LPX-54
error while parsing a stream to XOB
and I find no solution, can help me!
PROCEDURE ftpTransfer IS
vConn UTL_TCP.connection;;
vFileName VARCHAR2(50);
vToFile VARCHAR2(200);
BEGIN
fileTransfer(vFileName);
IF vFileName IS NULL THEN
raise_application_error(-20002,'FTP - Erreur de Fichier');
END IF;
vToFile := RPLPKG_PARAMETERS.gServer.sDir||vFileName;
vConn := ftp.login(RPLPKG_PARAMETERS.gServer.sHost, RPLPKG_PARAMETERS.gServer.sHost, RPLPKG_PARAMETERS.gServer.sPort, RPLPKG_PARAMETERS.gServer.sPsw);
ftp.ascii(p_conn => vConn);
ftp.put(p_conn => vConn,
p_from_dir => 'RPLDIRECTORY',
p_from_file => 'HRM10122019.csv',
p_to_file => '/JOURNALS/HRM10122019.csv');
ftp.logout(vConn);
END ftpTransfer;
screenshot

Oracle Datapump: Invalid operation at line 6224

I've a Oracle dump file that I'm trying to import to AWS RDS Oracle 12.1.0.2.v17
database.
The dump file looks like this:
$ strings EXPDP.dmp | head -n 6
_|lM
"PACOPROD"."SYS_EXPORT_SCHEMA_01"
IBMPC/WIN_NT64-9.1.0
unicode
AL32UTF8
12.01.00.00.00
The commands I'm running is:
DECLARE
hdnl NUMBER;
BEGIN
hdnl := DBMS_DATAPUMP.OPEN( operation => 'IMPORT', job_mode => 'SCHEMA', job_name=>null, version=>'COMPATIBLE');
DBMS_DATAPUMP.ADD_FILE( handle => hdnl, filename => 'EXPDP.dmp', directory => 'DATA_PUMP_DIR', filetype => dbms_datapump.ku$_file_type_dump_file);
DBMS_DATAPUMP.METADATA_FILTER(hdnl,'SCHEMA_EXPR','IN (''PACOPROD'')');
DBMS_DATAPUMP.START_JOB(hdnl);
END;
/
The response is:
Error report -
ORA-39002: invalid operation
ORA-06512: at "SYS.DBMS_DATAPUMP", line 6224
ORA-06512: at line 7
The closes similar issue I've found is this, even though it's not exactly the same error message and in my case both source and target db is running 12.1.
I think the issue is one of the following:
A) The DMP file is corrupt.
B) I'm doing something wrong.
I've no clue how to get further though. Where shall I dig or what should I try to go forward?
Try to add a log file to the operation. It some times contain more information:
DBMS_DATAPUMP.ADD_FILE( handle => hdnl, filename => 'EXPDP.log', directory => 'DATA_PUMP_DIR', filetype => dbms_datapump.KU$_FILE_TYPE_LOG_FILE);

FTP a file from a Server's Subfolder using PL/SQL

I'm trying to get a file from a Windows Server to our Oracle Application Server directory named EXT_TAB_DATA.
I have followed the sample of a similar SO post (PL/SQL FTP API binary vs ascii mode), using Tim Hall's FTP Package.
Code Block
set serveroutput on
DECLARE
l_conn UTL_TCP.connection;
BEGIN
L_CONN := FTP.login (p_host => 'sample.corp.server' -- this is a sample, not the real IP address
p_user => 'corporate/user1', -- this is a sample, not the real User
p_port => '21',
p_pass => 'pwd');
ftp.binary(p_conn => l_conn);
ftp.get (p_conn => l_conn,
p_from_file => '101_Test.csv',
p_to_dir => 'EXT_TAB_DATA',
p_to_file => '101_Test_Trans.csv');
ftp.logout(l_conn);
END;
/
However, the file i'm trying to transfer is located in a subfolder named "Payroll_Folder" in "sample.corp.server.
Seems FTP.login only checks the main directory of the host, and not inside subfolders.
How can I get the the file '101_Test.csv' from the Server/Directory "sample.corp.server/Payroll_Folder"?
Change
p_from_file => '101_Test.csv'
to
p_from_file => 'Payroll_Folder/101_Test.csv'

Run exe from DBMS_SCHEDULER

I am kind of new in DMBS_SCHEDULER and I face some problems.
I want to run an .exe
So I created a Job:
begin
sys.dbms_scheduler.create_job(job_name => 'FTREC.EXE_1',
job_type => 'EXECUTABLE',
job_action => 'C:\Windows\System32\calc.exe',
start_date => to_date(null),
repeat_interval => '',
end_date => to_date(null),
job_class => 'IRECS_JOB_CLASS',
enabled => false,
auto_drop => false,
comments => '');
end;
I have also created credentials :
DBMS_SCHEDULER.CREATE_CREDENTIAL('WWLSERVER','WWLSERVER','1234',null,null,null);
And I applied the credentials to my job
dbms_scheduler.set_attribute('FTREC.EXE_1', 'credential_name', 'WWLSERVER');
But when I try to run my Job I get this error:
EXTERNAL_LOG_ID="job_255737_183883",
ORA-27369: job of type EXECUTABLE failed with exit code: The extended attributes are inconsistent.
What I am doing wrong?
Credentials were not available in 10g. There are no mentions of the word "credential" in the
DBMS_SCHEDULER documentation.
I was able to run your code in 12c. But running calc.exe created an un-killable session, I had to restart the database. Things went much better when I used a simple .bat file for testing.
This thread on the Oracle Forums has methods for running an external program on 10g.

Problem creating a Directory object in Oracle

The code is this:
Originally:(http://www.oracle-base.com/articles/misc/FTPFromPLSQL.php)
The approach uses a combination of the UTL_TCP and UTL_FILE packages to create a simple FTP API (ftp.pks, ftp.pkb). Once the API is loaded into the appropriate schema simple FTP commands can be initiated as follows:
CREATE OR REPLACE DIRECTORY my_docs AS '/u01/app/oracle/';
SET SERVEROUTPUT ON SIZE 1000000
#c:\ftp.pks
#c:\ftp.pkb
-- Send an ASCII file to a remote FTP server.
DECLARE
l_conn UTL_TCP.connection;
BEGIN
l_conn := ftp.login('ftp.company.com', '21', 'ftpuser', 'ftppassword');
ftp.ascii(p_conn => l_conn);
ftp.put(p_conn => l_conn,
p_from_dir => 'MY_DOCS',
p_from_file => 'test_get.txt',
p_to_file => '/u01/app/oracle/test_put.txt');
ftp.logout(l_conn);
END;
/
The problem is that when I try to create the directory object I get an error saying that Create symbol wasnt expected.
where this line should be created?
Is there anything preceding the create statement line in your script? It looks like there might be something you left off the post.

Resources