Sponsored Content
Top Forums Shell Programming and Scripting Sftp some files from windows server to UNIX server Post 302761361 by vinit raj on Friday 25th of January 2013 01:35:57 PM
Old 01-25-2013
Sftp some files from windows server to UNIX server

hi

i need to transfer some files from windows server to unix server using SFTP. but before transferring the files, i need to check the
existence of a particular file in the remote directory (say r_dir1). if the file is present, then SFTP all the files.
after SFTPing the files from the remote directory (r_dir1) to unix directory, i need to move the files from remote directory (r_dir1)
to some other remote directory (say dir2) in the same windows server only.


i am using the following code



Code:
#! /bin/ksh

TARGET_DIR=<path of target directory>
FILE_NAME_TO_CHECK=<file_name>
REMOTE_USER=<user_name>
REMOTE_MACHINE=<windows server name>
REMOTE_DIR=<path of windows directory>

cd ${TARGET_DIR}

sftp ${REMOTE_USER}@${REMOTE_MACHINE} <<EOF
cd ${REMOTE_DIR}
if [[ -f "$REMOTE_DIR"/"$FILE_NAME_TO_CHECK" ]]; then     
    get *                          # downloading all the files
    mv * <path of the r_dir2>             
else
    echo "$FILE_NAM the E_TO_CHECK doesn't exist so cant copy other files"
fi

--------------------------------------------------------------------------------------------------------------
# files are getting SFTPed to the unix server but

errors:
1:- showing "if" and "else" statements as invalid commands
2:- showing "mv" command as invalid


please, some body provide me a solution.. i need it urgently

Last edited by joeyg; 01-25-2013 at 02:49 PM.. Reason: Please wrap commands and data with CodeTags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

SFTP from windows E:/ to unix server

Hello All :), I am making a script in the ksh to Secure FTP a set of files from the E:/ drive in windows a computer to a unix server. Had it been in the unix directory, I could have used the expect utility to use the non-interactive mode for sftp, #!/usr/local/bin/expect #!/bin/ksh ... (12 Replies)
Discussion started by: pranavagarwal
12 Replies

2. Shell Programming and Scripting

SFTP failure from unix to windows server

Hi, I am having unix server SUNW,Sun-Fire-V245. remote windows server details: Microsoft Windows In my script i am sftp'ing files to the windows server through sftp command. But the problem i am facing is, some files are successfully sftp'd to windows server and for some files sftp is... (0 Replies)
Discussion started by: syamkp
0 Replies

3. Shell Programming and Scripting

FTPing files from unix server to windows server

Hi, Below is the script which ftps the file from unix server and putting in a different directory(but on unix server) How can i ftp the files from unix server and to place in a secure location on windows server? what changes needs to be done to the below script? How can this be... (1 Reply)
Discussion started by: venkatesht
1 Replies

4. Shell Programming and Scripting

Error copying files from Unix (Solaris10) to Windows Server 2003 using scp/sftp

Hi, I have generated a Public/Private Key Pair in Solaris Unix (source) server and deployed the Public key in Windows 2003(target) server .ssh directory of user profile. When i try to connect(ssh, scp, sftp) from Unix, i'm getting below error message. Sun_SSH_1.1, SSH protocols 1.5/2.0,... (0 Replies)
Discussion started by: ajaykumarb
0 Replies

5. Shell Programming and Scripting

Unix shell script to Copy files from one Windows server to another Windows server.

Can anybody please help me on how to code for the below requirement: I need to write a shell script (on different unix server) to copy files from multiple folders (ex. BRN-000001) from one windows server (\\boldls-mwe-dev4)to a different windows server(\\rrwin-ewhd04.ecomad.int). This shell... (4 Replies)
Discussion started by: SravsJaya
4 Replies

6. IP Networking

How to transfer files from UNIX server to windows machine or vice versa using ftp or sftp commands?

hi, i want to write a shell script code which transfers files from a directory in unix server to a directory in a windows machine.. can any1 give me a sample code which uses ftp or sftp command.. thanks very much, (3 Replies)
Discussion started by: Little
3 Replies

7. Shell Programming and Scripting

Needed SFTP script from windows to UNIX server and from UNIX to windows server(reverse SFTP)

hi guys, i need a script to sftp the file from windows to unix server ....(before that i have to check whether the file exists in the windows server or not and again i have to reverse sftp the files from unix to windows server..... regards, Vasa Saikumar. (13 Replies)
Discussion started by: hemanthsaikumar
13 Replies

8. Solaris

FTP-ing files from Windows server to UNIX server

I need to transfer files from a Windows server to the Unix server and have to run some shell script on it to get the required output. Is it possible to transfer files from Windows server to unix server through any shell script? If so can you please help me with the details. Thanks in... (8 Replies)
Discussion started by: ssk250
8 Replies

9. Shell Programming and Scripting

Copying the files to Windows server from UNIX server

Hi Team, I had a requirement to write a shell script which automatically transfer the files from unix server to windows server. I can able to unix to unix using Scp command. I am not sure how to do unix to windows. I am very new on this concept. Could you please help me or guide in... (4 Replies)
Discussion started by: gvkumar25
4 Replies

10. Shell Programming and Scripting

Do I require remote login access to a windows server to transfer files from a UNIX server

Hi All I need to transfer a file from a UNIX server to a windows server. I saw that it is possible to do this using scp command by looking at the forum listed below: ... (2 Replies)
Discussion started by: vx04
2 Replies
CURLOPT_FTP_CREATE_MISSING_DIRS(3)			     curl_easy_setopt options				CURLOPT_FTP_CREATE_MISSING_DIRS(3)

NAME
CURLOPT_FTP_CREATE_MISSING_DIRS - create missing dirs for FTP and SFTP SYNOPSIS
#include <curl/curl.h> typedef enum { CURLFTP_CREATE_DIR_NONE, CURLFTP_CREATE_DIR, CURLFTP_CREATE_DIR_RETRY } curl_ftpcreatedir; CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FTP_CREATE_MISSING_DIRS, long create); DESCRIPTION
Pass a long telling libcurl to create the dir. If the value is CURLFTP_CREATE_DIR (1), libcurl will attempt to create any remote directory that it fails to "move" into. For FTP requests, that means a CWD command fails. CWD being the command that changes working directory. For SFTP requests, libcurl will attempt to create the remote directory if it can't obtain a handle to the target-location. The creation will fail if a file of the same name as the directory to create already exists or lack of permissions prevents creation. Setting create to CURLFTP_CREATE_DIR_RETRY (2), tells libcurl to retry the CWD command again if the subsequent MKD command fails. This is especially useful if you're doing many simultaneous connections against the same server and they all have this option enabled, as then CWD may first fail but then another connection does MKD before this connection and thus MKD fails but trying CWD works! DEFAULT
CURLFTP_CREATE_DIR_NONE (0) PROTOCOLS
FTP and SFTP EXAMPLE
TODO AVAILABILITY
Added in 7.10.7. SFTP support added in 7.16.3. The retry option was added in 7.19.4. RETURN VALUE
Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if the create value is not. SEE ALSO
CURLOPT_FTP_FILEMETHOD(3), CURLOPT_FTP_USE_EPSV(3), libcurl 7.54.0 February 03, 2016 CURLOPT_FTP_CREATE_MISSING_DIRS(3)
All times are GMT -4. The time now is 05:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy