SFTP stderror not able to trap


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting SFTP stderror not able to trap
# 1  
Old 12-18-2013
SFTP stderror not able to trap

# 2  
Old 12-18-2013
Yes ?
Where is the content of your post?
This User Gave Thanks to vbe For This Post:
# 3  
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
# 4  
Old 12-19-2013
does the if part get executed? I have doubts on the second EOF...
It would be easier to rewrite your script using what sftp allows / has to offer like -b batchfile where you can write a script that can look for the presence of files etc...

Last edited by vbe; 12-19-2013 at 10:40 AM.. Reason: added doubts about second EOF...
# 5  
Old 12-19-2013
Bumping up posts or double posting is not permitted in these forums. If we don't answer your thread immediately, WAIT!. We are not "on call".

Please read the rules, which you agreed to when you registered, if you have not already done so.

You may receive an infraction for this. If so, don't worry, just try to follow the rules more carefully. The infraction will expire in the near future

Thank You.

The UNIX and Linux Forums.
# 6  
Old 12-20-2013
Hi,

Sorry, when i posted first time unfortunately i forget to post the code/program. after that i tried to delete the thread. but couldn't find the delete option. so i posted new thread.
sorry, i will keep in mind for the future.

Thanks,
krupa

---------- Post updated at 02:39 AM ---------- Previous update was at 12:06 AM ----------

Hi,

if part is executing, but it is giving the same result(output indicator 0 always eventhough it sftp is unsuccess).

as per your given instruction i tried with below.
Code:
sftp  -b techoutluc.dat kdgehtr@udfertd01.ndc.lucent.com

it is giving me error like below.
Code:
FEEDS:/projects/feeds/abc/output>sftp  -b techoutluc.dat kdgehtr@udfertd01.ndc.lucent.com
sftp> 5982026    001263222USA18100283 USA0MA4William         NSalemme                  LP319600531        19370702          Q1M100605    20010713
Invalid command.

is there any way?.
please let me know i am stoke at that point, not able to go ahead.

Thanks,
Krupa

Last edited by Scott; 12-20-2013 at 07:18 AM.. Reason: Code tags
# 7  
Old 12-20-2013
Quote:
-b batchfile
Batch mode reads a series of commands from an input batchfile
instead of stdin. Since it lacks user interaction it should be
used in conjunction with non-interactive authentication. A
batchfile of '-' may be used to indicate standard input. sftp
will abort if any of the following commands fail: get, put,
rename, ln, rm, mkdir, chdir, ls, lchdir, chmod, chown, chgrp,
lpwd, df, and lmkdir. Termination on error can be suppressed on
a command by command basis by prefixing the command with a '-'
character (for example, -rm /tmp/blah*).
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

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

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

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

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

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

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

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

8. 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
Login or Register to Ask a Question