Sponsored Content
Top Forums Shell Programming and Scripting SFTP stderror not able to trap Post 302880335 by krupasindhu18 on Thursday 19th of December 2013 06:24:30 AM
Old 12-19-2013
Hi All,

Please see the below shells script for SFTP.
if ” techoutheh.dat” and “teckeytluc.dat” files are available in ${OUTDIR} directory location it is working fine.
Problem:- for -ve testing, if the above files are not available it should give error, but it is not giving any errors(giving status is ‘0' always).
Actually I don't know stderror for SFTP .
I mean to say whether files are exits or not it is giving me always exit status is ‘0'(success) that I have tested.


Can any body tell me how to trap the success or failure in SFTP.
Code:
  #!/bin/sh
  cd ${OUTDIR}
  sftp_output=`sftp kdgehtr@udfertd01.ndc.lucent.com << EOF
  cd /home/u1et8/oradata/x2ffgggadrop 
  mput techoutheh.dat teckeytluc.dat 
  bye 
  EOF`
   
  echo "sftp status :- ${sftp_output} \n sftp process output indicator ${?}" | grep -e 'Uploading' -e 'output indicator 0' > ${TECHFEED}/techfeed_sftp_status.txt
   
  err_found=`cat "${TECHFEED}/techfeed_sftp_status.txt" | grep -i 'output indicator 0'`
   
                                  if [ "${err_found}" = "" ]
                                  then
                                                  echo "*** Sending techfeed file to SPIRIT Server Failed - Abort"
                                                  cat <<-EOF | mailx -s "Sending techfeed file to SPIRIT Server Failed" $MAILLIST
                                                  " "
                                                                  EOF
                                  exit 1
                                  fi

---------- Post updated at 04:37 AM ---------- Previous update was at 01:34 AM ----------

Hi,

I have posted shells script. please check.

Thanks,
krupa

---------- Post updated at 06:23 AM ---------- Previous update was at 04:37 AM ----------

Hi All,

are you able to see my thread. if it is not visible please let me know... still i am looking foe solution.

thanks,
krupa
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Building a better mouse trap, or How many lines of code does it take to trap a mouse?

Hello all, I'm hoping to get a little insight from some of the wily veterans amongst you. I've written a script to check for new outgoing files to our vendors located on our ssl server. It seems to be working ok, but the final question here, will be one of logic, and/or a better way to... (4 Replies)
Discussion started by: mph
4 Replies

2. Shell Programming and Scripting

Cntl+z Trap is not detecting ??? Help required to add a trap detection ???

Hi folks, I have tried to add some trap detection in the below script....this script is used to monitor database activities...in a rather awkward way :rolleyes:.... The idea behind adding trap is that....this script creates lots of temporary files in the running folder to store the count... (1 Reply)
Discussion started by: frozensmilz
1 Replies

3. Programming

help with unix redirecting to stderror

when writing a script, when redirececting a message to stderror, how do i do it? i can have echo "message" 2> error.log is it neccessary to do it while creating a file, if not how do i send it to stderror and have it displayed on the screen at same time, and not have to create a file. (5 Replies)
Discussion started by: omega666
5 Replies

4. Shell Programming and Scripting

SFTP-how to log individual sftp command error while executing shell script

Hi, I have situation where i need to automate transferring 10000+ files using sftp. while read line do if ; then echo "-mput /home/student/Desktop/folder/$line/* /cygdrive/e/folder/$line/">>sftpCommand.txt fi done< files.txt sftp -b sftpCommand.txt stu@192.168.2.1 The above... (1 Reply)
Discussion started by: noobrobot
1 Replies

5. Shell Programming and Scripting

Automatically send stdout and stderror to a file as well as to the screen, but without using tee

Hi, I've been using the following commands in my automated scripts, to ensure that all text output is sent to a log file instead of to the screen: exec 1>>$SCRIPT_LOG_FILE exec 2>>$SCRIPT_LOG_FILE However, I've now discovered that the system used for automating the script executions... (4 Replies)
Discussion started by: confusedAdmin
4 Replies

6. Red Hat

Chroot sftp users, remote sftp login shows wrong timestamp on files

Hello, I have a weird issue, I have RHEL 5.7 running with openssh5.2 where sftpgroup OS group is chroot. I see the difference difference in timestamp on files, when I login via ssh and SFTP, I see four hour difference, is something missing in my configuration. #pwd... (8 Replies)
Discussion started by: bobby320
8 Replies

7. Homework & Coursework Questions

VM trap may work differently than a pure install trap.

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: That is the last reply I received from my instructor, and I'm looking for some alternatives. When using... (2 Replies)
Discussion started by: newuser45
2 Replies

8. Shell Programming and Scripting

Redirect stdout and stderror in child process

I have a problem when i try to create a log file from a daemon process using shell scripting in ubuntu 12. Ultimatly what i want to achieve is run a java/jar file from a script. After scourging the internet i found several solutions to do this, the one i choose is to create a startup script that... (4 Replies)
Discussion started by: Narev
4 Replies
libssh2_sftp_unlink_ex(3)					  libssh2 manual					 libssh2_sftp_unlink_ex(3)

NAME
libssh2_sftp_unlink_ex - unlink an SFTP file SYNOPSIS
#include <libssh2.h> #include <libssh2_sftp.h> int libssh2_sftp_unlink_ex(LIBSSH2_SFTP *sftp, const char *filename, unsigned int filename_len); int libssh2_sftp_unlink(LIBSSH2_SFTP *sftp, const char *filename); DESCRIPTION
sftp - SFTP instance as returned by libssh2_sftp_init(3) filename - Path and name of the existing filesystem entry filename_len - Length of the path and name of the existing filesystem entry Unlink (delete) a file from the remote filesystem. RETURN VALUE
Return 0 on success or negative on failure. It returns LIBSSH2_ERROR_EAGAIN when it would otherwise block. While LIBSSH2_ERROR_EAGAIN is a negative number, it isn't really a failure per se. ERRORS
LIBSSH2_ERROR_ALLOC - An internal memory allocation call failed. LIBSSH2_ERROR_SOCKET_SEND - Unable to send data on socket. LIBSSH2_ERROR_SOCKET_TIMEOUT - LIBSSH2_ERROR_SFTP_PROTOCOL - An invalid SFTP protocol response was received on the socket, or an SFTP operation caused an errorcode to be returned by the server. SEE ALSO
libssh2_sftp_init(3) libssh2 0.15 1 Jun 2007 libssh2_sftp_unlink_ex(3)
All times are GMT -4. The time now is 03:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy