FTP scrtip: Unix to windows directory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting FTP scrtip: Unix to windows directory
# 1  
Old 05-22-2007
Question FTP scrtip: Unix to windows directory

Hi, I'm trying to automate a ftp from a unix box to a windows directory. But i want it to count and only move the files if they are there so that i can cron it. This is what i have, but seems to be failing, can anyone spot what is going wrong?

#! /usr/bin/ksh

cd ????/????/par/942852
HOST=???.???.???.???
USER=USER
PASSWD=PWRD
count="$(find ????/????/par/942852/ -name "????*" -print | wc -l)"
if [[ $count -gt 0 ]]
then
exec 4>&1
ftp -nv >&4 2>&4 |&
print -p open $???.???.???.???
print -p user $USER $PWRD
print -p cd \\???.???.???\WINDOWS\SYSTEM
print -p ascii
print -p put ????*
print -p bye
wait
exit 0
else
exit 0
fi

cd ????/????/par/942852
mv ????* cd ????/????/par/942852/proc/
# 2  
Old 05-22-2007
Here are some suggestions that might help you.

Code:
COUNT=`ls /foo/bar/foobar* | wc -l`

may be better code then the find you have executing.

Then I would say if count didn't equal 0 then use
Code:
mput foobar*

in the ftp rather then
Code:
put foobar*

. I believe that using the wild card with put will fail.
# 3  
Old 05-23-2007
Data Syntax error

there is a syntax error here, anyone know what it is?

./ftp_?????.sh: line 10: syntax error near unexpected token `&'
./ftp_?????.sh: line 10: ` ftp -nv >&4 2>&4 |&'
# 4  
Old 05-23-2007
Tools Syntax error

Tried to remove the |& leaving:

ftp -nv >&4 2>&4

But then i just get the ftp prompt, there must be a way to automate this?
# 5  
Old 05-23-2007
What i do, but it might be over kill, is create a .netrc file in the home directory of the user that will be FTPing. The permissions set to 700. In the file I add the following.

machine [server] login [user] password [password]

The idea of the .netrc file is to allow FTPing without having to enter a user name and password.

So in your script you would put something similar...
example:
Code:
echo "cd /dropoff \n bin \n mput files* \n" | ftp -iv [server]

Hope that helps!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

FTP from windows to unix server using unix shell script

Hi, Is it possible to ftp a huge zip file from windows to unix server using unix shell scripting? If so what command i need to use. thanks in advance. (1 Reply)
Discussion started by: Shri123
1 Replies

2. Shell Programming and Scripting

UNIX script to FTP file from UNIX server to windows

Hi, I am new to this subject.....Can someone please help me out with the script... unix usernm "sdhftst" unix pwd "chsd13" windows usernm "dfghtst" windows pwd "chsd13" path..../xxx/xxxxx/xxxxxx/xxxxxxx please can u get me a script...its only one file to get ftp. Thanks... (2 Replies)
Discussion started by: himakiran9
2 Replies

3. AIX

Do I need to configure my local windows to FTP files from local windows to a UNIX AIX server?

Hi Friends, I have this script for ftping files from AIX server to local windows xp. #!/bin/sh HOST='localsystem.net' USER='myid_onlocal' PASSWD='mypwd_onlocal' FILE='file.txt' ##This is a file on server(AIX) ftp -n $HOST <<END_SCRIPT quote USER $USER quote PASS $PASSWD put $FILE... (1 Reply)
Discussion started by: rajsharma
1 Replies

4. Shell Programming and Scripting

FTP from Windows to UNIX

will this work, knowing that the file is in a directory in windows.. It is going from a drirectory in windoxs to UNIX \ # Error Handling Function function ErrorHandle { # if type is 1, then the file does not exist or unreadable if then echo "File... (5 Replies)
Discussion started by: rechever
5 Replies

5. Shell Programming and Scripting

Move a file from windows directory to unix directory

Move a file from windows directory to unix directory, is this possible? if it is, can someone help me on this? Thanks! God bless! (1 Reply)
Discussion started by: kingpeejay
1 Replies

6. Shell Programming and Scripting

ftp from windows to unix using a perl script on unix machine

i need to ftp a file from windows to a unix machine by executing a sript(perl/shell/php) from that unix machine.i can also use HTML and javascript to build forms. (3 Replies)
Discussion started by: raksha.s
3 Replies

7. Shell Programming and Scripting

ftp from unix to windows

How to do ftp from unix to windows i have some files in a dir in unix box and i want to put those files in windows through FTP. How to do this ? (9 Replies)
Discussion started by: ali560045
9 Replies

8. IP Networking

How to Transfer a whole Directory from unix to windows using FTP?

Hi I can transfer a single file and multiple file from unix to widows using get and mget command.But i dont know How to transfer a whole directory from unix to windows using command. pls help me Ramkumar (1 Reply)
Discussion started by: ramkumarm83
1 Replies

9. UNIX for Dummies Questions & Answers

ftp from unix to windows

Hi, I have been using ftp to transfer files back and forth between windows and unix machines. But everytime i started the ftp session from the windows machine. I have a question why I am not able to connect to the same windows machine from the same unix machine. How do I do this? ... (11 Replies)
Discussion started by: oldtrash
11 Replies

10. UNIX for Dummies Questions & Answers

moving files from a unix directory to a windows directory

Any body any ideas i'm failry new to this so any help would be appreciated. Cheers Steve (2 Replies)
Discussion started by: gleads
2 Replies
Login or Register to Ask a Question