Skip to main content

Accessing Files Using SFTP on Linux

Starting sftp

The command for starting sftp is as follows:
ComputerName:~# sftp user@host

Few Commands :

cd - change directory on the ftp server to
lcd - change directory on your machine to
ls - list files in the current directory on the ftp server
lls - list files in the current directory on your machine
pwd - print the current directory on the ftp server
lpwd - print the current directory on your machine.
exit - exit from the sftp program.

GET Command:

The get command in sftp allows you to download files from the sftp server.
Usage: get remote-path [local-path]

For example, to download a file named "foo.bar", the following command would be used:
sftp>get foo.bar
To download this file and save it as "readme.txt", the following command would be used:
sftp>get foo.bar readme.txt

Getting Multiple Files

To download more than one file from the sftp server use the mget command.
Usage: mget
mget works by expanding each filename listed and running a get command on each file. The files are copied into the local working directory, which can be changed with the lcd command.
For example, to download all the files in the remote working directory, the following command would be used:
sftp> mget ./*
To download all of the files ending with .txt the following command would be used:
sftp> mget ./*.txt

Recursive Copy with SCP

Note: scp is a separate program and must be executed from the Unix command line prompt. NOT within the SFTP client.
Usage: scp copy_from copy_to
For example, if you wanted to copy the file "foobar.txt" from the remote location to your own computer, use the command:
scp user@sftp.cae.wisc.edu:/path/to/foobar.txt /some/local/directory
Likewise, if you wanted to copy the file "foobar.txt" from your own computer to your CAE remote files, use the command:
scp /path/to/foobar.txt user@sftp.cae.wisc.edu:/some/remote/directory


Script to transfer file from FTP to local

#! /bin/bash
 sftp oracle_uxtrn360_rocs@ftpdev1.intra.schneider.com <<EOF
 cd basecsv
lcd /tmp/ftp
 get *.csv abc.csv  
EOF


Comments

Popular posts from this blog

Tune your JDeveloper 12c (12.1.3)

Is your JDeveloper 12c too slow, follow these 3 basic steps and increase perfomance of JDeveloper 12c  (12.1.3) Step 1:  Configure JVM settings in jdev.conf Path:  $MV_HOME$/jdeveloper/jdev/bin/jdev.conf # optimize the JVM for strings / text editing AddVMOption -XX:+UseStringCache AddVMOption -XX:+OptimizeStringConcat AddVMOption -XX:+UseCompressedStrings # if on a 64-bit system, but using less than 32 GB RAM, this reduces object pointer memory size AddVMOption -XX:+UseCompressedOops # use an aggressive garbage collector (constant small collections) AddVMOption -XX:+AggressiveOpts # for multi-core machines, use multiple threads to create objects and reduce pause times AddVMOption -XX:+UseConcMarkSweepGC AddVMOption -DVFS_ENABLE=true AddVMOption -Dsun.java2d.ddoffscreen=false AddVMOption -XX:+UseParNewGC AddVMOption -XX:+CMSIncrementalMode AddVMOption -XX:+CMSIncrementalPacing AddVMOption -XX:CMSIncrementalDutyCycleMin=0 AddVMOption -XX:CMSIncrementalDutyCycle=10 Step 2:

How to use Log4j logger in Simple few steps

Steps to follow : 1. Download Log4j Jar file  and add in Project Lib Path.        http://logging.apache.org/log4j/1.2/download.html 2. Create Log4j.properties file in your project and add below details.      log4j.rootLogger=DEBUG, Appender1,Appender2 log4j.appender.Appender1=org.apache.log4j.ConsoleAppender log4j.appender.Appender1.layout=org.apache.log4j.PatternLayout log4j.appender.Appender1.layout.ConversionPattern=%-7p %d [%t] %c %x - %m%n log4j.appender.Appender2=org.apache.log4j.FileAppender log4j.appender.Appender2.File= applog.txt log4j.appender.Appender2.layout=org.apache.log4j.PatternLayout log4j.appender.Appender2.layout.ConversionPattern=%-7p %d [%t] %c %x - %m%n 3. In the main method of Java program add below code.         Logger logger = Logger.getLogger(Conn.class);          String log4jConfigFile = System.getProperty("user.dir") + File.separator + "log4j.properties";         PropertyConfigurator.configure(log4jConfigFile);  

CHANGING THE INBOUND FILE ADAPTER ARCHIVE FILE NAME IN SOA

Default archive name will be filename_ digest _timestamp. This format was introduced with SOA 11g. To configure the File Adapter archive filename to use this format: filename_yyyymmdd_hh24mmss we have to use property “UseDigest” in JCA file. By default “UseDigest” is set to true, which tells the Inbound File Adapter that the archive file name format will be the default: filename_digest_timestamp. When the “UseDigest” property is set to false, the filename format will revert to: filename_timestamp. Modify your File Inbound JCA file, and add the following property: <property name=”UseDigest” value=”false”/>