KSH Script/FTP (NEWBIE)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting KSH Script/FTP (NEWBIE)
# 1  
Old 01-19-2006
KSH Script/FTP (NEWBIE)

I trying to write a ksh script (without the help of the Kermit libraries) which connects to a ftp server and checks if the file "KEI.done" exists. If the file exists it print "files is there" if it doesnt exist it prints "file is not there". (the print statements will later be replaced with code to process the file) Can someone please help me write a pice of code which can acoomplish this.

Thanks,
John
# 2  
Old 01-19-2006
Code:
#!/bin/ksh
export username="$1"
export password="$2"
export nodename="$3"
export LOG="./logfile"
export filename="/path/to/file/KEI.done"
export CMDFILE="./test.cmd"
{
  echo "verbose"
  echo "open $nodename"
  echo "user $username $password"
  echo "ls $filename"
  echo "quit"
} >$CMDFILE
ftp -n < $CMDFILE > $LOG 2>&1
grep -q "not found" $LOG
if [ $? -eq 0 ] ; then
	echo "$filename is not there"
else
    echo "$filename is there"
fi	
exit 0

# 3  
Old 01-19-2006
getting an error

I am getting the following error:

run1.ksh[16]: 0403-057 Syntax error at line 16 : `}' is not expected.

I am guessing its due to this block

{
echo "verbose"
echo "open $nodename"
echo "user $username $password"
echo "ls $filename"
echo "quit"
} >$CMDFILE

any ideas?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Having a hell of atime with KSH -ftp automation

Following this thread: https://www.unix.com/ip-networking/1935-automated-ftp-task.html I have created the following script: #! /bin/ksh HOST=ftp.mywebsite2.com USER=astrocloud PASSWD=8**** exec 4>&1 ftp -nv >&4 2>&4 |& print -p open $HOST print -p user $USER $PASSWD print -p cd... (3 Replies)
Discussion started by: Astrocloud
3 Replies

2. Shell Programming and Scripting

FTP in ksh script

Hi, I'm trying to get "ftp" commands work inside a function written in ksh script; but it seems to be not working!! Here's the code: function chk_ftp_path { IP_ADDR=$1 USER=$2 PASSWORD=$3 FTP_PATH=$4 ftp -ivn $IP_ADDR << EOF user $USER $PASSWORD cd $FTP_PATH quit EOF ... (9 Replies)
Discussion started by: dips_ag
9 Replies

3. Shell Programming and Scripting

KSH script to run other ksh scripts and output it to a file and/or email

Hi I am new to this Scripting process and would like to know How can i write a ksh script that will call other ksh scripts and write the output to a file and/or email. For example ------- Script ABC ------- a.ksh b.ksh c.ksh I need to call all three scripts execute them and... (2 Replies)
Discussion started by: pacifican
2 Replies

4. Shell Programming and Scripting

newbie: writing ksh shell problem

my default profile is using ksh, I tried to write a simple scripts and I had issues, below is my scripts: $ more if_num.ksh USAGE="usage: if_num.ksh" print -n "Enter two numbers: " read x y if ((x=y)) then print "You entered the same number twice." when I tried to executed the... (6 Replies)
Discussion started by: matthew00
6 Replies

5. Shell Programming and Scripting

How do I write a ksh script that will check if all ftp files are received?

I am trying to code a ksh script that will check to see if all 26 incoming ftp files have been received before proceeding to the next function, which is to rename each file. Here is the pseudo-code of what I am trying to do: <<STEP_1>> IF all ALS files have been transmitted then... (2 Replies)
Discussion started by: doug145
2 Replies

6. Shell Programming and Scripting

import var and function from ksh script to another ksh script

Ih all, i have multiples ksh scripts for crontab's unix jobs they all have same variables declarations and some similar functions i would have a only single script file to declare my variables, like: var1= "aaa" var2= "bbb" var3= "ccc" ... function ab { ...} function bc { ... }... (2 Replies)
Discussion started by: wolfhurt
2 Replies

7. Shell Programming and Scripting

KSH n FTP query

Hi, I have this slightly modified FTP code (thanks to this forum) function gather_FTPDate { HOST= USER= PASSWD= exec 4>${TEMP_LOG_FILE} ftp -nv >&4 2>&4 |& echo $? if ] then echo "Unable to connect to FTP server!!!" >> ${LOG_FILE} return 0 fi print -p open... (2 Replies)
Discussion started by: psynaps3
2 Replies

8. Shell Programming and Scripting

Newbie convert date ksh

If I have start = 02282006; end = 03152006; How do I get startdate = 02/28/2006; enddate = 03/15/2006; Thanks, (3 Replies)
Discussion started by: britney
3 Replies

9. Shell Programming and Scripting

Newbie problem with ksh script

Hi all, I have a directory have all of the .stat and .dat file : they are is a pipe separate flat file. Example: log-20061202.stat contain 1st line and last line of log-20061202.dat with record count of that day. Example: Total record = 240 Tom|02-12-2006|1600 W.Santa... (18 Replies)
Discussion started by: sabercats
18 Replies

10. Shell Programming and Scripting

FTP in a KSH script

Hi, I'm writing a script to perform automated ftp's. What I would like to know is if it is possible to examine return codes or trap any error messages from the remote server. eg. if during the ftp session i cd to a different directory on the remote server and the directory does not exist, can... (2 Replies)
Discussion started by: Bab00shka
2 Replies
Login or Register to Ask a Question