ftp files from Unix to Windows through shell program


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ftp files from Unix to Windows through shell program
# 1  
Old 04-28-2005
Question ftp files from Unix to Windows through shell program

Hi,
I made a shell script to allow user to ftp file to windows shared drive.
Here is part of my code within my shell script:
/usr/bin/ftpmtc $usr $pswd $jobno

Within 'ftpmtc':
#ARGUMENT: USER,PASWD,JOBNO,VER,LOG_DATE,$$
$UCB/echo "user $1 $2" > $inst_file
$UCB/echo "cd prod" >> $inst_file
$UCB/echo "ascii" >>$inst_file
$UCB/echo "cr" >> $inst_file
$UCB/echo "" >> $inst_file

$UCB/echo "lcd /tmp/prodhrs " >> $inst_file
$UCB/echo "put $3.prodhours $3prodhours " >> $inst_file

$UCB/echo "bye" >> $inst_file

$UCB/ftp -n mtc < $inst_file


The thing I am trying to do here is to use my shell program to ftp on the fly depending what kind of file we got from shell program.
I use echo command to create temp ftp script and use 'ftp -n mtc < ftp_script'
From my observation, if I don't use sh -x myprogram to run, I can't guarantee that the program ftp file to windows.
But if I use 'sh -x myprogram' to start, it seems always sucessful.
Does anyone know why it happend this way?

Thanks for your help!!
# 2  
Old 05-02-2005
Bug What happend?

No one reply ?
Does this mean that my question was not clearly stated or just no one knows why?
# 3  
Old 05-02-2005
do "chmod 755 myprogram" and run as "/dir/myprogram" or "./myprogram" if you're already in the directory ...
# 4  
Old 05-02-2005
chmod 755

Mine was already chmod 777.
I changed to chmod 755 but it didn't help.

?
# 5  
Old 05-02-2005
1. what is the actual command line you use that fails?

2. what is the PATH set for the script?

3. what are the first 3 lines of the script?
# 6  
Old 05-03-2005
Just Ice,
1. what is the actual command line you use that fails?
-- When I run my script program, I just type the program name like 'myprogram'. Within 'myprogram' there will be one line to provide argument to a script program to write a ftp file. Here is the line within 'myprogram':
/usr/bin/ftpmtc $usr $pswd $jobno

The 'ftpmtc' is a shell script program who write ftp command on the fly to a tmp file called $inst_file. Below is almost the whole program:
===============================================
Within 'ftpmtc':
#ARGUMENT: USER,PASWD,JOBNO,VER,LOG_DATE,$$
$UCB/echo "user $1 $2" > $inst_file
$UCB/echo "cd prod" >> $inst_file
$UCB/echo "ascii" >>$inst_file
$UCB/echo "cr" >> $inst_file
$UCB/echo "" >> $inst_file

$UCB/echo "lcd /tmp/prodhrs " >> $inst_file
$UCB/echo "put $3.prodhours $3prodhours " >> $inst_file

$UCB/echo "bye" >> $inst_file

$UCB/ftp -n mtc < $inst_file
================================
2. what is the PATH set for the script?
--the PATH for 'myprogram' is in /usr/bin and it's the same as ftpmtc file.

3. what are the first 3 lines of the script?
--A.
the first 3 lines of 'myprogram' is
#!/bin/sh
# Version "prodhrs --3 03/31/2005"
/usr/ucb/clear
--B.
the first 3 lines of 'ftpmtc' is:
#!/bin/sh
inst_file="$TEMP_PATH/ftp_inst.$$"
#ARGUMENT: USER,PASWD,JOBNO,VER,LOG_DATE,$$
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

I noticed that if I run 'myprogram' in the directory other than where it's located, it will not ftp files.

Thanks for your help!!
# 7  
Old 05-03-2005
Quote:
Originally Posted by whatisthis
I noticed that if I run 'myprogram' in the directory other than where it's located, it will not ftp files.
... sounds like you have a PATH problem with your external commands ... where is $UCB being set? is it at the script level or at your shell level? is the $PATH also being set at the script level or is it inherited from your shell?
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. 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

3. Shell Programming and Scripting

shell script to ftp the files from windows to unix server

Hi, I need to ftp some input files from windows to unix server.All the files will be saved in the C drive in my machine. Currently all these files are transferring manually to the unix server.I need to write a shell script which ftp the files from windows to unix box.When I searched in the... (10 Replies)
Discussion started by: kavithakuttyk
10 Replies

4. UNIX for Advanced & Expert Users

Shell script to ftp files from windows to unix

Hi , I need to ftp some input files from windows to unix server.All the files will be saved in the C drive in my machine.Currently all these files are transferring manually to the unix server.I need to write a shell script which ftp the files from windows to unix box.When I searched in the forum i... (1 Reply)
Discussion started by: kavithakuttyk
1 Replies

5. Shell Programming and Scripting

copying files from UNIX to windows using FTP

Hi, I want to transfer the approx 10k files available on UNIX Server to Windows Server using FTP Command. is it possible? how ? Thanks in advance. Sachin. (1 Reply)
Discussion started by: ssachins
1 Replies

6. Shell Programming and Scripting

FTP from unix shell script to windows

Hi, I m trying to connect/establish FTP from unix shell script to my PC.Below the script i have written #!/bin/ksh ftp -v -n ddcappip01.com << "EOF" user Amit jason bye EOF ------------------------------ERROR-------------------------- but i m getting the below error for the... (4 Replies)
Discussion started by: ali560045
4 Replies

7. Shell Programming and Scripting

FTP Unix Box to Windows Shell Script

Hello All, Could someone help me out with this? I want to incorporate this into an existing script so the output of a SAS job can be ftp'd from our UNIX box to a directory on a drive in Windows environment. Can this be done with no extra third party software? We currently use Putty for copy... (2 Replies)
Discussion started by: Jose Miguel
2 Replies

8. Shell Programming and Scripting

Shell to FTP file from Windows to unix

I need your help for a FTP Job to be schedule to copy files from windows to Unix. in a set of time interval. My requirement is as follows. 1.Script should check whether file is available in the windows folder , if available then do FTP to unix server , and then move... (3 Replies)
Discussion started by: sandeep.kamble
3 Replies

9. Shell Programming and Scripting

FTP Shell Scripts from Windows to Unix: files have exotic characters

Hey guys, I am working on my shell scripts in wordpad in windows. Then, I upload it to my unix using psftp, but when I open those files with "vi" in Unix, there are all these "^M" characters in the file. Would anyone of you have a clue as to why? Help would be appreciated. Thanks, Laud (4 Replies)
Discussion started by: Laud12345
4 Replies

10. Shell Programming and Scripting

transfer of files via ftp from windows to unix

I am currently looking to write a script to transfer files from a windows NT server to a unix server any ideas of how to go about this? (1 Reply)
Discussion started by: chambala5
1 Replies
Login or Register to Ask a Question