Sponsored Content
Full Discussion: ftp error trapping
Top Forums UNIX for Dummies Questions & Answers ftp error trapping Post 18709 by Bab00shka on Tuesday 2nd of April 2002 09:16:13 AM
Old 04-02-2002
Question ftp error trapping

Hi
I'm hoping I could get some help on the following. I'm writing a script which will in turn create an ftp script then excecute it. eg

echo "user $user $pass" > $script
echo "cd $remote_dir" >> $script
echo "bi" >> $script
echo "mput $file" >> $script
echo "bye" >> $script
ftp -n -i $ip < $script

I am having problems trapping errors if $remote_dir does not exist.

I've tried the following:

echo "cd $remote_dir" >> $script
echo "bi" >> $script
echo "mput $file" >> $script
echo "bye" >> $script
ftp -n -i $ip <$script
if [ $? -ne 0 ] then .......

This doesn't work because ftp always returns '0' even if $remote_ dir does not exist.

echo "cd $remote_dir" >> $script
echo "bi" >> $script
echo "mput $file" >> $script
echo "bye" >> $script
ftp -n -i $ip <$script 2>$error_file

Here an 'empty' error file is created on the remote server and error messages still display to screen.

How can I test for errors or how can I create an error file on the local server? Any help would be greatly appreciated!

Thanks Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sql error code trapping

Hello #!bin/ksh sqlplus -s system/manager < |grep '^ORA' |uniq select * from kk; set echo on show spool on end; / EOF save test.sh sh test.sh results ORA-00942: table or view does not exist (3 Replies)
Discussion started by: xiamin
3 Replies

2. UNIX for Dummies Questions & Answers

ftp error trapping

I have written a UNIX script that will automatically ftp a file to a server. The problem is when I missed enter information w/in the .txt file that contains the userid/password and what file to transfer, I had no way of capturing the failuer of the file transfer. I verified w/in the script that the... (1 Reply)
Discussion started by: dhawkjrscripter
1 Replies

3. Shell Programming and Scripting

Error Trapping

Hi, Can anybody tell me how to error trap an empty line. If i am asked for a password and I hit enter without entering any text, how do i display an error? Thanks Kev (6 Replies)
Discussion started by: kev112
6 Replies

4. Shell Programming and Scripting

trapping errors while using FTP.

Hello, I have the following shell script to perform ftp: ftp -n $HOST<<EOD quote USER $USER quote PASS $PASS lcd $outputd cd $dir binary put *.zip quit EOD If any error is generated from this script then how to trap the error. For ex: let's say we entered wrong password then the... (5 Replies)
Discussion started by: radhika
5 Replies

5. Shell Programming and Scripting

rcp error trapping in rsh

I am writing a program which is something like below: rsh host1 "rcp file dest:directory" I am running this script from a machine host2. host1 has rlogin configuration for host2. but, dest machine has no rlogin configuration for host1 and fails on remote calls. Could anyone tell me how... (2 Replies)
Discussion started by: vvejendla
2 Replies

6. Shell Programming and Scripting

Searching and FTP error trapping

This is gonna sound dumb but... 1 It seems that I cannot use the search function here properly. In researching to find a solution to an FTP error trapping issue, I go to the search option in the forum and use FTP as a search term and ask it to select all forums to search in..... I get no... (2 Replies)
Discussion started by: Bartman
2 Replies

7. Shell Programming and Scripting

trapping error for a grep in for a loop

How can I trap and print "cannot find the pattern" when the grep is unable to find the specified pattern in the file using the for loop below ? Any help would be appreciated. bash3.4> cat test_file apple orange pineapple blackberry script: for x in `grep -n "mango" test_file... (4 Replies)
Discussion started by: jville
4 Replies

8. Shell Programming and Scripting

curl error trapping in ksh

I hope that I can trap curl errors, and have my shell script error out and quit if curl has any sort of problem. For example, I have the following command in my shell script: curl --trace -n -v --ftp-ssl ftp://xxx.xxx.xxx.xxx:2122 --user user:password -o /tmp/file.txt Works great, except... (2 Replies)
Discussion started by: prestonatwork
2 Replies

9. Shell Programming and Scripting

Error Trapping

Hi, I have one shell script as below while read SegList do if test -s ${SourceFile_Path}/${Segment_List_Temp} then ls -r -1 ${FTP_Path}/${SegList}.DAT.${Datelist}.GZ|cut -d '.' -f2>>${SourceFile_Path}/${List_Temp} echo "IF above statment Fail I want to Create Emtpy File How to Trapp... (3 Replies)
Discussion started by: samadhanpatil
3 Replies

10. Shell Programming and Scripting

Trapping the error during copy

I have a requirement: During copy command for example: cp -rf <sourceDir> <destinationDir> this command may fails for many reasons like: 1. source or destination directory does not exist 2. destination directory does not have sufficient space 3. directories are not mounted ... Or may... (3 Replies)
Discussion started by: ambarginni
3 Replies
SCRIPT(1)						    BSD General Commands Manual 						 SCRIPT(1)

NAME
script -- make typescript of terminal session SYNOPSIS
script [-a] [-c COMMAND] [-f] [-q] [-t] [file] DESCRIPTION
Script makes a typescript of everything printed on your terminal. It is useful for students who need a hardcopy record of an interactive session as proof of an assignment, as the typescript file can be printed out later with lpr(1). If the argument file is given, script saves all dialogue in file. If no file name is given, the typescript is saved in the file typescript. Options: -a Append the output to file or typescript, retaining the prior contents. -c COMMAND Run the COMMAND rather than an interactive shell. This makes it easy for a script to capture the output of a program that behaves differently when its stdout is not a tty. -f Flush output after each write. This is nice for telecooperation: One person does `mkfifo foo; script -f foo' and another can super- vise real-time what is being done using `cat foo'. -q Be quiet. -t Output timing data to standard error. This data contains two fields, separated by a space. The first field indicates how much time elapsed since the previous output. The second field indicates how many characters were output this time. This information can be used to replay typescripts with realistic typing and output delays. The script ends when the forked shell exits (a control-D to exit the Bourne shell (sh(1)), and exit, logout or control-d (if ignoreeof is not set) for the C-shell, csh(1)). Certain interactive commands, such as vi(1), create garbage in the typescript file. Script works best with commands that do not manipulate the screen, the results are meant to emulate a hardcopy terminal. ENVIRONMENT
The following environment variable is utilized by script: SHELL If the variable SHELL exists, the shell forked by script will be that shell. If SHELL is not set, the Bourne shell is assumed. (Most shells set this variable automatically). SEE ALSO
csh(1) (for the history mechanism), scriptreplay(1). HISTORY
The script command appeared in 3.0BSD. BUGS
Script places everything in the log file, including linefeeds and backspaces. This is not what the naive user expects. AVAILABILITY
The script command is part of the util-linux-ng package and is available from ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/. Linux July 30, 2000 Linux
All times are GMT -4. The time now is 02:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy