Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles
New Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 

 

 

Oracle Shell Scripting

Oracle UNIX/Linux script tips

Transferring Files Between Systems

Transferring files between machines is often necessary for backups, duplicating databases, moving files from development to production systems and a host of other daily tasks.  There are several tools which can be used for moving files around, each with their advantages and disadvantages.  Here we?ll focus on the most flexible and secure tools available.

There are two tools which are typically available for securely transferring files between systems; sftp and scp.  Both offer ssh protocol security but they work somewhat differently.

sftp - Secure FTP

While sftp is typically used interactively in the same way the ftp application would be used, it can also read commands from a file in batch mode.  Here's an example of sftp being used interactively:

$ cd $ORACLE_HOME/network/admin
$ sftp sprog  
Connecting to sprog...
Password: password
sftp> cd /u01/app/oracle/product/10.2.0/db_1/network/admin
sftp> put tnsnames.ora
Uploading tnsnames.ora to /u01/app/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora
tnsnames.ora                                  100%  536     0.5KB/s   00:00   
sftp> quit

These steps could be combined either into a separate batch file (using the -b option then giving the file name) or redirected into sftp on the command line in the same fashion we have been using for SQL*Plus.

#!/bin/bash
#
cd $ORACLE_HOME/network/admin
sftp sprog << EOF
cd /u01/app/oracle/product/10.2.0/db_1/network/admin
put tnsnames.ora
exit
EOF

This short shell script will now automatically perform all the steps (except entering the password) that we accomplished interactively before.  The main commands within sftp are listed in the table below. 

Command

Action

quit

bye

Close the connection and exit sftp (either command will work)

get

Retrieve a file from the remote system

put

Upload a file to the remote system

ls

List the contents of a directory on the local system.  Many options which work with the ls command in the shell (like -l, -a and -t) also work with the ls command within sftp.

pwd

Show the current working directory on the remote system

cd

Change directory on the remote system

lpwd

Show the current working directory on the local system

lcd

Change directory on the local system

chmod

Change permissions of a given file

chown

Change ownership of a given file

chgrp

Change the group of a given file

rm

Remove a file from the remote system

rmdir

Remove a directory from the remote system

help

Display the online help for sftp

Many of these commands should be familiar and behave similarly to how they work in the shell.  The ability to change permissions and ownership and to remove remote files and directories can be very useful in our shell scripts.

 

This is an excerpt from the book "Oracle Shell Scripting" by Rampant TechPress. 

You can buy it directly from the publisher for only $34.95.  Also, see the Oracle script collection for over 600 working Oracle scripts to download.


 

 
��  
 
 
Oracle Training at Sea
 
 
 
 
oracle dba poster
 

 
Follow us on Twitter 
 
Oracle performance tuning software 
 
Oracle Linux poster
 
 
 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright © 1996 -  2017

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.

Remote Emergency Support provided by Conversational