|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 01:49 PM.. Reason: Please wrap commands and data with CodeTags |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
What about reading the
man stfp page? No
if , no
else , no
mv , but:
Quote:
BTW - your here document is missing its final token (EOF) |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Unix shell script to Copy files from one Windows server to another Windows server. | SravsJaya | Shell Programming and Scripting | 4 | 10-26-2011 02:26 AM |
| Help with Unix shell script to copy files from Unix server to Windows server | shankar1dada | Shell Programming and Scripting | 3 | 08-18-2011 06:17 PM |
| Error copying files from Unix (Solaris10) to Windows Server 2003 using scp/sftp | ajaykumarb | Shell Programming and Scripting | 0 | 07-21-2010 08:44 AM |
| FTPing files from unix server to windows server | venkatesht | Shell Programming and Scripting | 1 | 04-28-2009 09:54 AM |
| SFTP from windows E:/ to unix server | pranavagarwal | Shell Programming and Scripting | 12 | 11-28-2007 09:58 AM |
|
|