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!!

No one reply ?
Does this mean that my question was not clearly stated or just no one knows why?

do "chmod 755 myprogram" and run as "/dir/myprogram" or "./myprogram" if you're already in the directory ...

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

?

  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?

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

  1. what is the PATH set for the script?
    --the PATH for 'myprogram' is in /usr/bin and it's the same as ftpmtc file.

  2. 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!!

... 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?

Just Ice,
Thank you for your reply.
I found out where the problem is: I have a same named program in my home directory that I didn't know.
Once I deleted it , the problem is solved.

Thank you so much for your response otherwise I don't know where to look for.