SFTP in ASCII

Hi, I'm using TES 5.3.1 and I'm working on an FTP transmission to a bank.  They have asked that the file be sent SFTP in either ASCII or EBCDIC, but using the integrated FTP job, it only allows Binary when transferring SFTP.  Is there something I'm missing, or is ASCII SFTP not supported?
Thanks,
Scott

ASCII transfer mode for SFTP was added in Tidal Enterprise Scheduler 6.x.
John
Cisco TAC

Similar Messages

  • SFTP vs. ASCII/Binary distinction

    SFTP in Dreamweaver 8 does not, apparently, understand how to
    convert ASCII files from Windows (with CR LF line divisions) to
    Unix/Linux (LF line divisions). Non-secure FTP does, but that's a
    standard feature of the FTP protocol. Dreamweaver seems to just
    transfer ASCII file types in binary over SFTP, CR LF and all. So
    SFTP silently breaks .CGI files, which execute as shell scripts and
    won't run on Linux with CR LF line breaks. This can break your web
    site unexpectedly.
    (.HTML files work OK, because HTML format documents are
    indifferent to the CR LF / LF distinction. But that's not true of
    .CGI files.)
    Is there some workaround for this?

    John Nagle wrote:
    > shell scripts and won't run on Linux with CR LF line
    breaks. This can break
    > your web site unexpectedly.
    Edit > Preferences > Code Format. Select LF (Unix) as
    Line break type.
    David Powers, Adobe Community Expert
    Author, "The Essential Guide to Dreamweaver CS3" (friends of
    ED)
    Author, "PHP Solutions" (friends of ED)
    http://foundationphp.com/

  • Transfering files in ASCII mode using SFTP

    Hi All,
    We are using SFTP to transfer our files since we are using VPN. But we need a file to be transfered in ASCII mode from the remote system. We are using toad for that, but i heard that SFTP transfers file only in Binary mode by default. Is there any way to achieve it.?
    Thanks
    Narain

    Hi Narain,
    SFTP transfers files in Binary mode only as it transfers over SSH - so it is upto the sending/receiving client to manage the line endings.
    In BPEL,a java embedding can be used to convert line endings and then the payload handed over to FTP adapter for SFTP.
    Regards,
    Shanmu.

  • FTP to SFTP.

    Hi,
    My application is using ftp to connect to the server. but now it is going to change to sftp. For that I am not able to get what are the things in need to change in my ftp program to make it support for sftp. The following is the ftpbean class and the methods of the class are used by other classes. sftp is already installed and the environment is ready now. but I am not able to proceed where to modify the java..Please help.
    import java.beans.PropertyChangeListener;
    import java.beans.PropertyChangeSupport;
    import java.io.*;
    import java.net.Socket;
    import java.net.ServerSocket;
    import java.util.StringTokenizer;
    import java.util.Vector;
    public class FtpBean
    private String server = ""; // server name
    private String user = ""; // user name
    private String replyMessage = ""; // reply message from server
    private String reply = ""; // reply to the command
    private Socket socket; // Socket for FTP connection
    private BufferedReader in; // Input for FTP connection
    private PrintWriter out; // Output for FTP connection
    private int port = 21; // FTP port number, default 21
    private boolean passive = true; // Passive mode transfer, default true
    // Needed for thread safety
    private int[] lock = new int[0]; // For synchronized locking
    private boolean acquired = false; // Count the number of acquire
    private Vector threadSpool = new Vector(); // Spool for the waiting threads
    // Needed for some Visual tools
    private PropertyChangeSupport pcs; // PropertyChangeSupport for visual tools
    final private boolean DEBUG = false; // True to turn on debug mode
    * Constructor
    public FtpBean()
    pcs = new PropertyChangeSupport(this);
    * Add PropertyChangeListener
    public void addPropertyChangeListener(PropertyChangeListener listener)
    pcs.addPropertyChangeListener(listener);
    * removePropertyChangeListener
    public void removePropertyChangeListener(PropertyChangeListener listener)
    pcs.removePropertyChangeListener(listener);
    * Connect to FTP server and login.
    * @param server Name of server
    * @param user User name for login
    * @param password Password for login
    * @exception FtpException if a ftp error occur (eg. Login fail in this case).
    * @exception IOException if an I/O error occur
    public void ftpConnect(String server, String user, String password)
    throws IOException, FtpException
    if (DEBUG) // Debug message
    System.out.println("FtpBean: Connecting to server " + server);
    acquire(); // Acquire the object
    // Set server name & user name
    setServerName(server);
    setUserName(user);
    try {
    // Create socket, get input & output stream
    socket = new Socket(server, port);
    in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
    out = new PrintWriter(socket.getOutputStream(), true);
    // Read reply code when get connected
    getRespond();
    if (DEBUG) // Debug message
    System.out.println("FtpBean: Connected");
    // Login
    ftpLogin(user, password); // check if login success
    finally {
    release(); // Release the object
    * Close FTP connection.
    * @exception IOException if an I/O error occur
    * @exception FtpException if a ftp error occur
    public void close()
    throws IOException, FtpException
    if (out == null)
    return;
    acquire(); // Acquire the object
    try {
    ftpCommand("QUIT");
    if (!reply.startsWith("221"))
    throw new FtpException(reply);
    closeSocket();
    // Set server name & user name to ""
    setServerName("");
    setUserName("");
    finally {
    release(); // Release the object
    * Delete a file at the FTP server.
    * @param filename Name of the file to be deleted.
    * @exception FtpException if a ftp error occur. (eg. no such file in this case)
    * @exception IOException if an I/O error occur.
    public void fileDelete(String fileName)
    throws IOException, FtpException
    acquire(); // Acquire the object
    try {
    ftpCommand("DELE " + fileName);
    if (!reply.startsWith("250"))
    throw new FtpException(reply);
    finally {
    release(); // Release the object
    * Rename a file at the FTP server.
    * @param oldFileName The name of the file to be renamed
    * @param newFileName The new name of the file
    * @exception FtpException if a ftp error occur. (eg. A file named the new file name already in this case.)
    * @exception IOException if an I/O error occur.
    public void fileRename(String oldFileName, String newFileName)
    throws IOException, FtpException
    acquire(); // Acquire this object
    try {
    ftpCommand("RNFR " + oldFileName);
    if (!reply.startsWith("350"))
    throw new FtpException(reply);
    ftpCommand("RNTO " + newFileName);
    if (!reply.startsWith("250"))
    throw new FtpException(reply);
    finally {
    release(); // Release the object
    private boolean isSameSystem()
    throws IOException, FtpException
    String sysType = getSystemType();
    return (sysType.toUpperCase().indexOf("WINDOWS") < 0);
    * @param ftpFile Name of file to be get from the ftp server, can be in full path.
    * @param localFile File name of local file
    * @exception FtpException if a ftp error occur. (eg. No such file in this case)
    * @exception IOException if an I/O error occur.
    * @see FtpObserver
    public void getAsciiFile(String ftpFile, String localFile)
    throws IOException, FtpException
    getAsciiFile(ftpFile, localFile, null);
    * @param ftpFile Name of file to be get from the ftp server, can be in full path.
    * @param localFile File name of local file
    * @param observer The FtpObserver which monitor this downloading progress
    * @exception FtpException if a ftp error occur. (eg. No such file in this case)
    * @exception IOException if an I/O error occur.
    * @see FtpObserver
    public void getAsciiFile(String ftpFile, String localFile, FtpObserver observer)
    throws IOException, FtpException
    if (isSameSystem()) {
    getBinaryFile(ftpFile, localFile, observer);
    return;
    acquire(); // Acquire the object
    setTransferType(true); // Set transfer type to ascii
    Socket sock = null;
    try {
    sock = getDataSocket("RETR " + ftpFile, 0);
    // Read bytes from server and write to file.
    BufferedReader din = new BufferedReader(new InputStreamReader(sock.getInputStream()));
    PrintWriter dout = new PrintWriter(new BufferedWriter(new FileWriter(localFile)));
    char[] cbuf = new char[2048];
    int n;
    while ((n = din.read(cbuf, 0, cbuf.length)) != -1) {
    if (skipLineSepFilter())
    dout.write(cbuf, 0, n);
    else {
    // filter DOS line-sep to UNIX line-sep
    String data = filterLineSep(cbuf, n);
    dout.write(data, 0, data.length());
    if (observer != null)
    observer.byteRead(n);
    String data = null;
    while ((data = din.readLine()) != null) {
    dout.println(data);
    if (observer != null)
    observer.byteRead(data.length() + 1);
    din.close();
    dout.close();
    sock.close();
    getRespond();
    if (!reply.startsWith("226"))
    throw new FtpException(reply); // transfer incomplete
    finally {
    release(); // Release the object
    public void putAsciiFile(String localFile, String remoteFile, FtpObserver observer)
    throws IOException, FtpException
    acquire(); // Acquire the object
    setTransferType(true);
    // if file is to be transferred to MF, without slash, exec quote site cmd
    if (!remoteFile.startsWith("/"))
    setQuoteSite();
    Socket sock = null;
    try {
    // Read bytes from local file and write to a server.
    BufferedReader din = new BufferedReader(new FileReader(localFile));
    sock = getDataSocket("STOR " + remoteFile, 0);
    PrintWriter dout = new PrintWriter(new BufferedWriter(new OutputStreamWriter(sock.getOutputStream())));
    String data = null;
    while ((data = din.readLine()) != null) {
    //dout.println(data);
    dout.write(data);
    dout.write("\r\n");
    if (observer != null)
    observer.byteWrite(data.length() + 1);
    din.close();
    dout.close();
    sock.close();
    getRespond();
    if (DEBUG) // Debug message
    System.out.println("FtpBean: Reply is " + reply);
    putAsciiFile()
    Changed manner of checking if transfer is complete by checking the
    string Transfer Complete in the reply.
    For UNIX: Reply is 226 Transfer complete.
    For MF: Reply is 250 Transfer completed successfully.
    //if (!reply.startsWith("226"))
    int m = 0;
    if ((m = reply.indexOf("Transfer complete")) < 0)
    throw new FtpException(reply); // transfer incomplete
    finally {
    release(); // Release the object
    * Read file from ftp server and write to a file in local hard disk.
    * This method is much faster than those method which return a byte array<br>
    * if the network is fast enough.<br>
    * <br>Remark:<br>
    * Cannot be used in unsigned applet.
    * @param ftpFile Name of file to be get from the ftp server, can be in full path.
    * @param localFile Name of local file to be write, can be in full path.
    * @exception FtpException if a ftp error occur. (eg. No such file in this case)
    * @exception IOException if an I/O error occur.
    public void getBinaryFile(String ftpFile, String localFile)
    throws IOException, FtpException
    getBinaryFile(ftpFile, localFile, 0, null);
    * Read file from ftp server and write to a file in local hard disk.
    * This method is much faster than those method which return a byte array<br>
    * if the network is fast enough.<br>
    * <br>Remark:<br>
    * Cannot be used in unsigned applet.
    * @param ftpFile Name of file to be get from the ftp server, can be in full path.
    * @param localFile Name of local file to be write, can be in full path.
    * @param restart Restarting point
    * @exception FtpException if a ftp error occur. (eg. No such file in this case)
    * @exception IOException if an I/O error occur.
    public void getBinaryFile(String ftpFile, String localFile, long restart)
    throws IOException, FtpException
    getBinaryFile(ftpFile, localFile, restart, null);
    * Read file from ftp server and write to a file in local hard disk.
    * This method is much faster than those method which return a byte array<br>
    * if the network is fast enough.<br>
    * <br>Remark:<br>
    * Cannot be used in unsigned applet.
    * @param ftpFile Name of file to be get from the ftp server, can be in full path.
    * @param localFile Name of local file to be write, can be in full path.
    * @param observer The FtpObserver which monitor this downloading progress
    * @exception FtpException if a ftp error occur. (eg. No such file in this case)
    * @exception IOException if an I/O error occur.
    * @see FtpObserver
    public void getBinaryFile(String ftpFile, String localFile, FtpObserver observer)
    throws IOException, FtpException
    getBinaryFile(ftpFile, localFile, 0, observer);
    * Read from a ftp file and restart at a specific point.
    * This method is much faster than those method which return a byte array<br>
    * if the network is fast enough.<br>
    * Remark:<br>
    * Cannot be used in unsigned applet.
    * @param ftpFile Name of file to be get from the ftp server, can be in full path.
    * @param localFile File name of local file
    * @param restart Restarting point, ignored if equal or less than zero.
    * @param observer The FtpObserver which monitor this downloading progress
    * @exception FtpException if a ftp error occur. (eg. No such file in this case)
    * @exception IOException if an I/O error occur.
    * @see FtpObserver
    public void getBinaryFile(String ftpFile, String localFile, long restart, FtpObserver observer)
    throws IOException, FtpException
    acquire(); // Acquire the object
    setTransferType(false); // Set transfer type to binary
    Socket sock = null;
    try {
    sock = getDataSocket("RETR " + ftpFile, restart);
    // Read bytes from server and write to file.
    BufferedInputStream din = new BufferedInputStream(sock.getInputStream());
    RandomAccessFile dout = new RandomAccessFile(localFile, "rw");
    dout.seek(restart);
    byte[] data = new byte[1024];
    int n;
    while ((n = din.read(data)) != -1) {
    dout.write(data, 0, n);
    if (observer != null)
    observer.byteRead(n);
    din.close();
    dout.close();
    sock.close();
    getRespond();
    if (!reply.startsWith("226"))
    throw new FtpException(reply); // transfer incomplete
    finally {
    release(); // Release the object
    * Read a file from local hard disk and write to the server.
    * <br>Remark:<br>
    * <br>Cannot be used in unsigned applet.
    * @param local_file Name of local file, can be in full path.
    * @param remoteFile Name of file in the ftp server, can be in full path.
    * @exception FtpException if a ftp error occur. (eg. permission denied)
    * @exception IOException if an I/O error occur.
    public void putBinaryFile(String localFile, String remoteFile)
    throws IOException, FtpException
    putBinaryFile(localFile, remoteFile, 0, null);
    * Read a file from local hard disk and write to the server.
    * <br>Remark:<br>
    * <br>Cannot be used in unsigned applet.
    * @param localFile Name of local file, can be in full path.
    * @param remoteFile Name of file in the ftp server, can be in full path.
    * @param observer The FtpObserver which monitor this uploading progress.
    * @exception FtpException if a ftp error occur. (eg. permission denied)
    * @exception IOException if an I/O error occur.
    public void putBinaryFile(String localFile, String remoteFile, FtpObserver observer)
    throws IOException, FtpException
    putBinaryFile(localFile, remoteFile, 0, observer);
    * Read a file from local hard disk and write to the server with restarting point.
    * Remark:<br>
    * Cannot be used in unsigned applet.
    * @param localFile Name of local file, can be in full path.
    * @param remoteFile Name of file in the ftp server, can be in full path.
    * @param restart The restarting point, ignored if less than or greater than zero.
    * @exception FtpException if a ftp error occur. (eg. permission denied)
    * @exception IOException if an I/O error occur.
    public void putBinaryFile(String localFile, String remoteFile, long restart)
    throws IOException, FtpException
    putBinaryFile(localFile, remoteFile, restart, null);
    * Read a file from local hard disk and write to the server with restarting point.
    * Remark:<br>
    * Cannot be used in unsigned applet.
    * @param localFile Name of local file, can be in full path.
    * @param remoteFile Name of file in the ftp server, can be in full path.
    * @param observer The FtpObserver which monitor this uploading progress
    * @exception FtpException if a ftp error occur. (eg. permission denied)
    * @exception IOException if an I/O error occur.
    public void putBinaryFile(String localFile, String remoteFile, long restart, FtpObserver observer)
    throws IOException, FtpException
    acquire(); // Acquire the object
    setTransferType(false);
    Socket sock = null;
    try {
    RandomAccessFile din = new RandomAccessFile(localFile, "r");
    sock = getDataSocket("STOR " + remoteFile, restart);
    if (restart > 0)
    din.seek(restart);
    DataOutputStream dout = new DataOutputStream(sock.getOutputStream());
    byte[] data = new byte[1024];
    int n;
    while ((n = din.read(data)) != -1) {
    dout.write(data, 0, n);
    if (observer != null)
    observer.byteWrite(n);
    din.close();
    dout.close();
    sock.close();
    getRespond();
    putBinaryFile()
    Changed manner of checking if transfer is complete by checking the
    string Transfer Complete in the reply.
    For UNIX: Reply is 226 Transfer complete.
    For MF: Reply is 250 Transfer completed successfully.
    //if (!reply.startsWith("226"))
    int m = 0;
    if ((m = reply.indexOf("Transfer complete")) < 0)
    throw new FtpException(reply); // transfer incomplete
    finally {
    release(); // Release the object
    * Get current directory name.
    * @return The name of the current directory.
    * @exception FtpException if a ftp error occur.
    * @exception IOException if an I/O error occur.
    public String getDirectory()
    throws IOException, FtpException
    acquire(); // Acquire the object
    try {
    ftpCommand("PWD");
    if (!reply.startsWith("257"))
    throw new FtpException(reply);
    int first = reply.indexOf("\"");
    int last = reply.lastIndexOf("\"");
    return reply.substring(first + 1, last);
    finally {
    release(); // Release the object
    * Change directory.
    * @param directory Name of directory
    * @exception FtpException if a ftp error occur. (eg. permission denied in this case)
    * @exception IOException if an I/O error occur.
    public void setDirectory(String directory)
    throws IOException, FtpException
    acquire(); // Acquire the object
    try {
    ftpCommand("CWD " + directory);
    if (!reply.startsWith("250"))
    throw new FtpException(reply);
    finally {
    release(); // Release the object
    * Change to parent directory.
    * @exception FtpException if a ftp error occur. (eg. permission denied in this case)
    * @exception IOException if an I/O error occur.
    public void toParentDirectory()
    throws IOException, FtpException
    acquire(); // Acquire the object
    try {
    ftpCommand("CDUP");
    if (!reply.startsWith("250"))
    throw new FtpException(reply);
    finally {
    release(); // Release the object
    * Get the content of current directory
    * @return A FtpListResult object, return null if it is not connected.
    * @exception FtpException if a ftp error occur. (eg. permission denied in this case)
    * @exception IOException if an I/O error occur.
    * @see FtpListResult
    public FtpListResult getDirectoryContent()
    throws IOException, FtpException
    String strList = getDirectoryContentAsString();
    FtpListResult ftpList = new FtpListResult();
    ftpList.parseList(strList, getSystemType());
    return ftpList;
    * Get the content of current directory.
    * @return A list of directories, files and links in the current directory.
    * @exception FtpException if a ftp error occur. (eg. permission denied in this case)
    * @exception IOException if an I/O error occur.
    public String getDirectoryContentAsString()
    throws IOException, FtpException
    StringBuffer list = new StringBuffer(""); // Directory list
    Socket sock = null; // Socket to establish data connection
    acquire(); // Acquire the object
    try {
    // get DataSocket for the LIST command.
    // As no restarting point, send 0.
    sock = getDataSocket("LIST", 0);
    BufferedReader din = new BufferedReader(new InputStreamReader(sock.getInputStream()));
    // Read bytes from server.
    String line;
    while ((line = din.readLine()) != null)
    list.append(line).append("\n");
    din.close();
    sock.close();
    getRespond();
    if (!reply.startsWith("226"))
    throw new FtpException(reply);
    finally {
    release(); // Release the object
    return list.toString();
    * Make a directory in the server.
    * @param directory The name of directory to be made.
    * @exception FtpException if a ftp error occur. (eg. permission denied in this case)
    * @exception IOException if an I/O error occur.
    public void makeDirectory(String directory)
    throws IOException, FtpException
    acquire(); // Acquire the object
    try {
    ftpCommand("MKD " + directory);
    if (!reply.startsWith("257"))
    throw new FtpException(reply);
    finally {
    release(); // Release the object
    * Remove a directory in the server
    * @param directory The name of directory to be removed
    * @exception FtpException if a ftp error occur. (eg. permission denied in this case)
    * @exception IOException if an I/O error occur.
    public void removeDirectory(String directory)
    throws IOException, FtpException
    acquire(); // Acquire the object
    try {
    ftpCommand("RMD " + directory);
    if (!reply.startsWith("250"))
    throw new FtpException(reply);
    finally {
    release(); // Release the object
    * Execute a command using ftp.
    * e.g. chmod 700 file
    * @param exec The command to execute.
    * @exception FtpException if a ftp error occur. (eg. command not understood)
    * @exception IOException if an I/O error occur.
    public void execute(String exec)
    throws IOException, FtpException
    acquire(); // Acquire the object
    try {
    ftpCommand("SITE " + exec);
    if (!reply.startsWith("200"))
    throw new FtpException(reply);
    finally {
    release(); // Release the object
    private String _ftpSystemType = null;
    * Get the type of operating system of the server.
    * Return null if it is not currently connected to any ftp server.
    * @return Name of the operating system.
    public String getSystemType()
    throws IOException, FtpException
    if (_ftpSystemType != null)
    return _ftpSystemType;
    acquire(); // Acquire the object
    try {
    ftpCommand("SYST");
    if (!reply.startsWith("215"))
    throw new FtpException(reply);
    _ftpSystemType = reply.substring(4);
    return _ftpSystemType;
    finally {
    release(); // Release the object
    * Return the port number
    public int getPort()
    return port;
    * Set port number if the port number of ftp is not 21
    public void setPort(int port)
    acquire(); // Acquire the object
    pcs.firePropertyChange("port", new Integer(this.port), new Integer(port));
    this.port = port;
    release(); // Release the object
    * Return the server name. Return "" if it is not connected to any server.
    public String getServerName()
    return server;
    * Return the user name. Return "" if it is not connected to any server.
    public String getUserName()
    return user;
    * Get reply of the last command.
    * @return Reply of the last comomand<br>for example: 250 CWD command successful
    public String getReply()
    return reply;
    * Get reply message of the last command.
    * @return Reply message of the last command<br>for example:<br>
    * 250-Please read the file README<br>
    * 250-it was last modified on Wed Feb 10 21:51:00 1999 - 268 days ago
    public String getReplyMessage()
    return replyMessage;
    * Return true if it is using passive transfer mode.
    public boolean isPassiveModeTransfer()
    return passive;
    * Set passive transfer mode. Default is true.
    * @param passive Using passive transfer if true.
    public void setPassiveModeTransfer(boolean passive)
    acquire(); // Acquire the object
    pcs.firePropertyChange("passiveModeTransfer", new Boolean(this.passive), new Boolean(passive));
    this.passive = passive;
    if (DEBUG) // debug message
    System.out.println("FtpBean: Set passive transfer - " + passive);
    release(); // Release the object
    * Close the Socket, input and output stream
    private void closeSocket()
    throws IOException
    _ftpSystemType = null;
    in.close();
    out.close();
    socket.close();
    in = null;
    out = null;
    socket = null;
    * Read the respond message from the server's inputstream and assign to replyMessage
    private void getRespond()
    throws IOException
    String line = "";
    String replyMessage = "";
    while (true) {
    // Problem.....
    line = in.readLine();
    if (!checkReply(line))
    break;
    replyMessage = replyMessage.concat(line).concat("\n");
    setReplyMessage(replyMessage);
    setReply(line);
    * Login to server, using FTP commands "USER" and "PASS"
    * @param user FTP username
    * @param password FTP Password
    private void ftpLogin(String user, String password)
    throws IOException, FtpException
    ftpCommand("USER " + user); // send user name
    ftpCommand("PASS " + password); // send password
    if (!reply.startsWith("230")) {
    closeSocket();
    throw new FtpException(reply);
    * Send FTP command to the server.
    * @param command The command to be sent
    private void ftpCommand(String command)
    throws IOException
    if (DEBUG) {  // Debug message
    if (command.startsWith("PASS"))
    System.out.println("FtpBean: Send password");
    else
    System.out.println("FtpBean: Send command \"" + command + "\"");
    out.print(command + "\r\n"); // Send command
    out.flush();
    getRespond();
    * Establish data connection for transfer
    private Socket getDataSocket(String command, long restart)
    throws IOException, FtpException
    Socket sock = null;
    ServerSocket ssock = null;
    // Establish data conncetion using passive or active mode.
    if (passive)
    sock = getPassiveDataSocket();
    else
    ssock = getActiveDataSocket();
    // Send the restart command if it is greater than zero
    if (restart > 0) {
    ftpCommand("REST " + restart);
    if (!reply.startsWith("350"))
    throw new FtpException(reply);
    // Send commands like LIST, RETR and STOR
    // These commands will return 125 or 150 when success.
    ftpCommand(command);
    if (!(reply.startsWith("125") || reply.startsWith("150")))
    throw new FtpException(reply); // command file
    // Get Socket object for active mode.
    if (!passive)
    sock = ssock.accept();
    return sock;
    * Establish data connection in passive mode using "PASV" command
    * Change the server to passive mode.
    * by the command "PASV", it will return its address
    * and port number that it will listen to.
    * Create a Socket object to that address and port number.
    * Then return the Socket object.
    private Socket getPassiveDataSocket()
    throws IOException, FtpException
    ftpCommand("PASV");
    if (!reply.startsWith("227"))
    throw new FtpException(reply);
    // array that holds the outputed address and port number.
    String[] address = new String[6];
    // put the 'reply' to the array 'address'
    StringTokenizer t = new StringTokenizer(reply, ",");
    for (int i = 0; i < 6; i++)
    address[i] = t.nextToken();
    // Get port number.
    // Erase all other characters except the port number
    // which is at the beginning of the string
    String lastPort = "";
    int num = 3;
    if (address[5].length() < 3)
    num = address[5].length();
    for (int i = 0; i < num; i++) {
    if (Character.isDigit(address[5].charAt(i)))
    lastPort = lastPort + address[5].charAt(i);
    // assign last port number to address[5]
    address[5] = lastPort;
    // Get the port number
    // Left shift the first number by 8
    int newPort = (Integer.parseInt(address[4]) << 8) + Integer.parseInt(address[5]);
    // Create a new socket object
    Socket sock = new Socket(getServerName(), newPort);
    return sock;
    * Establish data connection in active mode using "PORT" command.
    * It create a ServerSocket object to listen for a port number in local machine.
    * Use port command to tell the server which port the local machine is listenning.
    * Return the ServerSocket object.
    private ServerSocket getActiveDataSocket()
    throws IOException, FtpException
    int[] portNumbers = new int[6]; // Array that contains
    // Get ip address of local machine. ip address and port numbers
    String localAddr = socket.getLocalAddress().getHostAddress();
    // Assign the ip address of local machine to the array.
    StringTokenizer st = new StringTokenizer(localAddr, ".");
    for (int i = 0; i < 4; i++)
    portNumbers[i] = Integer.parseInt(st.nextToken());
    ServerSocket ssocket = new ServerSocket(0); // ServerSocket to listen to a random free port number
    int localPort = ssocket.getLocalPort(); // The port number it is listenning to
    // Assign port numbers the array
    portNumbers[4] = ((localPort & 0xff00) >> 8);
    portNumbers[5] = (localPort & 0x00ff);
    // Send "PORT" command to s

    You would have to pick a library to do that. There are several commercial libraries. Out of the open source ones, the most mature one seems to be Ganymed SSH-2.

  • Setting File transfer mode in SFTP using JSch (jsch-20070302.jar)

    Hi,
    I use Jsch for downloading and uploading files via SFTP. I am a facing a problem in the file transfer mode. When I download or upload manually the files seems file, but when I use my code to download or upload there is some problem. Actally the file has to be transferred in ASCII mode, but the code transfers it in binary mode. Below is the code I am using
    +import com.jcraft.jsch.*
    Session session = null;
    try {
    populateProperties();
    log("INFO","Download and Encrypt Program started",getDateTime());
    JSch jsch = new JSch();
    String host = tumbleweedURL;
    String user = tUserid;
    session = jsch.getSession(user, host, 22);
    session.setUserInfo(new MyUserInfo());
    session.setPassword(tPassword);          
    session.connect();
    Channel channel = session.openChannel("sftp");
    channel.connect();
    ChannelSftp c = (ChannelSftp) channel;
    c.cd("outbox");
    c.get("8",outFolderPath);
    }+
    Please tell me how I change the transfer mode to ASCII for the above code

    Vignesh_kumar wrote:
    I am not sure where to put this question, I have tried a lot of things and I am not able to find a solution for this. Will you be able to guide me..A mailing list, or forum, or faq, or support address at JCraft, maybe?

  • How to code j2ssh SFTP in Binary mode??

    Dear Friends:
    I use java to code j2ssh SFTP, but I did not know How to use j2ssh send/retrieve file in binary mode or ASCII mode, Please advise if any good suggestion.
    Regards.
    sunny

    http://www.faqs.org/rfcs/rfc959.html

  • SFTP using JAva

    Hi,
    I want to use SFTP(FTP over SSH) to transfer files to a remote server and I am currently using Jsch from Jcraft. But apparently this does not support transferring files in ASCII mode, it uses binary mode by default. I need to transfer the files in both ASCII as well as in Binary mode. Can anyone help me out on this?

    ArchanaSrinivasan wrote:
    What you told made sense but actually I need to send a request file to a network element which expects ASCII content to do its processing. ASCII files transfered in 'binary' mode are still ASCII after the transfer. All 'binary' means is that no end-of-line conversion is done.
    Of course this transfer mode is made configurable so that depending on the necessity we should send either the binary file or the ASCII file.Not really! The ASCII mode converts the end-of-line character(s) as required so that they match the receiving end default. No other changes take place. While there are applications that worry about the end-of-line (Notepad for example) most other applications do not care and are happy to accept both. So, only if the application processing the file needs exactly the right end-of-line do you need to worry about ASCII mode.
    P.S. I hold the view that the second biggest mistake made in the FTP specification was to have the transfer modes ASCII, BINARY and EBCDIC since all these conversions should be done after the transfer. The biggest mistake was in making the default mode ASCII.

  • DW CC 2014 SFTP newlines

    Greetings All,
    Using DW CC 2014 on Win8.1 transferring php files to a UNIX server we are seeing ^M a problem with carriage returns and newlines.
    Server Model: PHP MySQL
    Preferences > Code Format > Line break type: CR LF (Windows)
    These same settings * were* working fine in DW CS4, I believe the php file transfer type is ascii , I am not sure where to check in CC 2014, is there an xml file ?
    Some how I suspect the DW CC 2014 is not handling the SFTP ascii transfer correctly. When we use another SFTP client the file transfer is correct.
    Am I missing some setting in DW CC 2014 ?
    Thanks for any help you can provide.
    -Rb

    Hi Lefing,
    See this discussion Re: Dreamweaver CC 2014 and Server Behaviors. I am locking this post so that we can have all this discussion in one forum post.
    Thanks,
    Preran

  • SFTP from PL-SQL

    I have generate a CSV file using PL SQL
    I know how to transfer file using FTP
    but now I want to Transfer the same file using SFTP
    How do I do the same.

    I write PL SQL for FTP
    following is the code
    CREATE OR REPLACE PROCEDURE Sp_Generate_Csv
    IS
         l_file_name VARCHAR2(50);
         l_dir_name VARCHAR2(50) := 'DIR';
         l_query VARCHAR2(32767) := 'SELECT * FROM employee';
    l_conn UTL_TCP.connection;
    BEGIN
         l_file_name := trim(TO_CHAR(SYSDATE,'yyyymmdd'))||'_report.txt';
         Csv.generate( l_dir_name, l_file_name, l_query );
         l_conn := Ftp.login('someIpAdd', '21', 'user', 'password');
    Ftp.ASCII(p_conn => l_conn);
    Ftp.put(p_conn => l_conn,
    p_from_dir => l_dir_name,
    p_from_file => l_file_name,
    p_to_file => l_file_name);
    Ftp.logout(l_conn);
         -- Exception handeling
         EXCEPTION
         WHEN OTHERS THEN
    Sp_Log_Error( SQLERRM, 'SP_GENERATE_RA_CSV' );
    RAISE;
    END Sp_Generate_Csv;
    How do I do using SFTP

  • Ftp to sftp conversion

    Hi,
    I am using one shell script for file transfer wich is currently using ftp.
    Now I have a requirment to use sftp instead of ftp.
    Below is the script which is being used for file transfer.....
    ============================
    set -x
    #!/bin/sh
    # Command line parameters are
    # 1- File name
    # 2- Host
    # 3- User ID
    # 4- Password
    # 5-Virtual Folder
    # 6-Retry Interval
    # 7- No of Retries
    # 8- FTP result Directory
    # 9- MAIL TO ADDRESS
    #10- Ascii File Directory
    #echo $@ > /tmp/myparams.lst
    FILE=$5
    HOST=$6
    USER=$7
    PASSWD=$8
    VIRTUAL_FOLDER=$9
    RETRY_INTERVAL=10
    NUM_RETRIES=3
    FTP_RESULT_DIR=/data/tmp
    MAIL_TO_ADDR=[email protected]
    FILE_DIR=/data/tmp
    BASE=" "
    I=0
    RESULT_DIR="${FTP_RESULT_DIR}"
    LOG_DIR="${FTP_RESULT_DIR}/MY_DATA_FILE_SSS.log"
    rm MY_DATA_FILE_SSS.log
    function connect
    ftp -nv $HOST > $LOG_DIR <<END_SCRIPT
    quote USER $USER
    quote PASS $PASSWD
    lcd $FILE_DIR
    if [ $FILE="MY_DATA_FILE" ] then
    quote site recfm=fb
    quote site lrecl=111
    pwd
    put $FILE 'MY_DATA_FILE_SSS'
    fi
    quit
    END_SCRIPT
    while [ $I -lt $NUM_RETRIES ]
    do
    connect
    if grep "Transfer complete" $LOG_DIR
    then
    echo "Success"
    exit 0
    elif [ $I -lt $NUM_RETRIES ]
    then
    # echo "Error1"
    ((I=I+1))
    sleep $RETRY_INTERVAL
    else
    echo "error"     
    exit 0
    fi
    done
    SUBJECT="FTP to ${HOST} Done"
    mailx -s "${SUBJECT}" $MAIL_TO_ADDR < $LOG_DIR
    ======================================
    Can anybody help me to replace the ftp with sftp in this script?
    Thanks in Advance,
    Roopak

    It is not that difficult. The main difference is that sftp uses a different means of authentication. Thus the username and password (and ftp quote ) commands are not relevant.
    As for the sftp list of commands - very similar to ftp. I suggest that you try this conversion yourself. Will be a valuable exercise that will increase your knowledge.
    The list of commands:
    sftp> help
    Available commands:
    cd path                       Change remote directory to 'path'
    lcd path                      Change local directory to 'path'
    chgrp grp path                Change group of file 'path' to 'grp'
    chmod mode path               Change permissions of file 'path' to 'mode'
    chown own path                Change owner of file 'path' to 'own'
    df [path]                     Display statistics for current directory or
                                  filesystem containing 'path'
    help                          Display this help text
    get remote-path [local-path]  Download file
    lls [ls-options [path]]       Display local directory listing
    ln oldpath newpath            Symlink remote file
    lmkdir path                   Create local directory
    lpwd                          Print local working directory
    ls [path]                     Display remote directory listing
    lumask umask                  Set local umask to 'umask'
    mkdir path                    Create remote directory
    progress                      Toggle display of progress meter
    put local-path [remote-path]  Upload file
    pwd                           Display remote working directory
    exit                          Quit sftp
    quit                          Quit sftp
    rename oldpath newpath        Rename remote file
    rmdir path                    Remove remote directory
    rm path                       Delete remote file
    symlink oldpath newpath       Symlink remote file
    version                       Show SFTP version
    !command                      Execute 'command' in local shell
    !                             Escape to local shell
    ?                             Synonym for help

  • Convert smart quotes and other high ascii characters to HTML

    I'd like to set up Dreamweaver CS4 Mac to automatically convert smart quotes and other high ASCII characters (m-dashes, accent marks, etc.) pasted from MS Word into HTML code. Dreamweaver 8 used to do this by default, but I can't find a way to set up a similar auto-conversion in CS 4.  Is this possible?  If not, it really should be a preference option. I code a lot of HTML emails and it is very time consuming to convert every curly quote and dash.
    Thanks,
    Robert
    Digital Arts

    I too am having a related problem with Dreamweaver CS5 (running under Windows XP), having just upgraded from CS4 (which works fine for me) this week.
    In my case, I like to convert to typographic quotes etc. in my text editor, where I can use macros I've written to speed the conversion process. So my preferred method is to key in typographic letters & symbols by hand (using ALT + ASCII key codes typed in on the numeric keypad) in my text editor, and then I copy and paste my *plain* ASCII text (no formatting other than line feeds & carriage returns) into DW's DESIGN view. DW displays my high-ASCII characters just fine in DESIGN view, and writes the proper HTML code for the character into the source code (which is where I mostly work in DW).
    I've been doing it this way for years (first with GoLive, and then with DW CS4) and never encountered any problems until this week, when I upgraded to DW CS5.
    But the problem I'm having may be somewhat different than what others have complained of here.
    In my case, some high-ASCII (above 128) characters convert to HTML just fine, while others do not.
    E.g., en and em dashes in my cut-and-paste text show as such in DESIGN mode, and the right entries
        &ndash;
        &mdash;
    turn up in the source code. Same is true for the ampersand
        &amp;
    and the copyright symbol
        &copy;
    and for such foreign letters as the e with acute accent (ALT+0233)
        &eacute;
    What does NOT display or code correctly are the typographic quotes. E.g., when I paste in (or special paste; it doesn't seem to make any difference which I use for this) text with typographic double quotes (ALT+0147 for open quote mark and ALT+0148 for close quote mark), which should appear in source code as
        &ldquo;[...]&rdquo;
    DW strips out the ASCII encoding, displaying the inch marks in DESIGN mode, and putting this
        &quot;[...]&quot;
    in my source code.
    The typographic apostrophe (ALT+0146) is treated differently still. The text I copy & paste into DW should appear as
        [...]&rsquo;[...]
    in the source code, but instead I get the foot mark (both in DESIGN and CODE views):
    I've tried adjusting the various DW settings for "encoding"
        MODIFY > PAGE PROPERTIES > TITLE/ENCODING > Encoding:
    and for fonts
        EDIT > PREFERENCES > FONTS
    but switching from "Unicode (UTF-8)" to "Western European" hasn't solved the problem (probably because in my case many of the higher ASCII characters convert just fine). So I don't think it's the encoding scheme I use that's the problem.
    Whatever the problem is, it's caused me enough headaches and time lost troubleshooting that I'm planning to revert to CS4 as soon as I post this.
    Deborah

  • To display non US-ASCII filename in file download dialog - Help Needed

    Hi,
    Our application supports to upload a file with name in chinese/japanese language. When user tries to download filedownload dialog box is appearing with the filename as junk characters.
    How to solve this issue to display the filename as uploaded.
    Thanks in advance
    ~kans

    bsampieri, issue is in display of the file name in
    file download dialog.
    ~kansI understood that, but my thought was that the HTTP headers content type containing a charset of UTF-8 might help. I don't know for sure, but otherwise, I don't know how to get the browser to otherwise not assume ASCII.

  • What is the diffrence between ASCII and BIN mode

    Hello All,
    What is the diffrence between ASCII and BIN mode
    Regards,
    Lisa.

    'ASC' :
    ASCII format. The table is transferred as text. The conversion exits are
    carried out. The output format additionally depends on the parameters
    CODEPAGE, TRUNC_TRAILING_BLANKS, and TRUNC_TRAILING_BLANKS_EOL.
    'IBM' :
    ASCII format with IBM codepage conversion (DOS). This format correspond
    to the 'ASC' format when using target codepage 1103. This codepage is
    often used for data exchange by disc.
    'DAT' :
    Column-by-column transfer. With this format, the data is transferred as
    with ASC text. However, no conversion exists are carried out and the
    columns are separated by tab characters. This format creates files that
    can be uploaded again with gui_upload or ws_upload.
    'DBF' :
    The data is downloaded in dBase format. Because in this format the file
    types of the individual columns are included, import problems, for
    example, into Microsoft Excel can be avoided, especially when
    interpreting numeric values.
    'WK1' :
    The data is downloaded in Lotus 1-2-3 format.
    'BIN' :
    Binary format. The data is transferred in binary format. There is no
    formatting and no codepage conversion. The data is interpreted row by
    row and not formatted in columns. Specify the length of the data in
    parameter BIN_FILESIZE. The table should consist of a column of type X,
    because especially in Unicode systems the conversion of structured data
    into binary data leads to errors.

  • Wrong ASCII values for control characters in Variables and Stack Call in CVI2013?

    Hi,
    I think there is an error in  "Variables and Call Stack" window if you want to look for your variables in ASCII format.
    The control characters (0 -  31) are not shown correct. They are shifted 2.
    For example:
    Character in Decimal format is 10 (LF) but when you are chancing to ASCII format it is showing \012.
    The same with 13 (CR). This character is \015 in ASCII format.
    I think that was no problem in CVI2012.
    Best regards
    Gunther
    Solved!
    Go to Solution.

    I'm not using CVI2013 yes so I cannot respond regarding this specific product, but the code you are showing are the octal equivalent of the decimal value you specified: it could be that control characters (or generally speacking non-printable ones) are replaced with their octal equivalent in string view.
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

  • Using secure FTP (SFTP) with XI 3.0.

    Hi,
    I must bring a document with SFTP protocol.
    Is it possible use SFTP with XI 3.0. What must I do use SFTP with XI. Is it necessary to install some component to XI or it needs some 3hrd party components?
    Thanks

    Hi Cemil,
    Right now, XI does not have the feature of communicating with SFTP. You can extend the functionality of the File Adapter by writing some adapter modules to enable it to communicate with SFTP.
    Regards,
    Hari.

Maybe you are looking for

  • What i've to do to run QuarkXpress 7.31 on MAC OS X 10.6.8

    I'm having problems with my QuarkXpress 7.31 running on MAC OS X 10.6.8. When i dispatch a job to printer the program just stop working after the job print and open a window with title "Bug Reporter" that display the following message: "Gathering sys

  • Calling executable file

    Hi all, I have made one classical report in which i am taking output in text file. Now for printing that text file i have made one BATCH File (Executable file of DOS). So is there any command to execute that batch file directly from my report? Thanks

  • Creation of BOM with Items whose qty is not fixed derived from a formula.

    Bom need to be created for a finished product whose Item quantities are ot fixed. The scenario is explained below. Raw milk(cow and buffalo) is a Raw Material recd from Vendors in litres.It is converted to kg as 1L = 1.027Kg.Finished Header material

  • CCIE Collaboration Lab

    Let say I came into a little extra cash and I wantto build a good CCIE Collaboration Lab for people that are studying for the exam to use.  I would like ot ask you the following questions: 1. What equipment and licenses should I purchase?  My budget

  • Photoshop cs4 rectangle tool error

    Hi I am using photoshop cs4. In my cs4, rectangle tool having a problem see this image