Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8880575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:11:20+00:00 2026-06-14T20:11:20+00:00

I have a simple main shell script that does a few prep things and

  • 0

I have a simple “main” shell script that does a few prep things and then calls another shell script that uploads a file to an ftp site. I’d like to know how I can wait and check the exit code of the called shell script and also how I could easily check whether the FTP file was actually successfully uploaded and provide a proper exit code (0 or 1)

thank you

main script:

#!/bin/sh
# check for build tools first
FTP_UPLOAD_SCRIPT=~/Desktop/ftp_upload.sh

if [ -f "$FTP_UPLOAD_SCRIPT" ]; then
    echo "OK 3/5 ftp_upload.sh found. Execution may continue"
else
    echo "ERROR ftp_upload.sh not found at $FTP_UPLOAD_SCRIPT. Execution cannot continue."
exit 1
fi

  # upload the packaged installer to an ftp site
  sh $FTP_UPLOAD_SCRIPT

  # check the ftp upload for its exit status
  ftp_exit_code=$?
  if [[ $ftp_exit_code != 0 ]] ; then
    echo "FTP ERRORED"
    exit $ftp_exit_code
  else
    echo $ftp_exit_code
    echo "FTP WENT FINE"
  fi

  echo "\n"
  exit 0

ftp_upload_script:

#!/bin/sh
FTP_HOST='myhost'
FTP_USER='myun'
FTP_PASS='mypass'

FTPLOGFILE=logs/ftplog.log
LOCAL_FILE='local_file'
REMOTE_FILE='remote_file'

ftp -n -v $FTP_HOST <<SCRIPT >> ${FTPLOGFILE} 2>&1
quote USER $FTP_USER
quote PASS $FTP_PASS
binary
prompt off
put $LOCAL_FILE $REMOTE_FILE
bye
SCRIPT
echo $!
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T20:11:20+00:00Added an answer on June 14, 2026 at 8:11 pm

    I have come up with a solution that both double checks the ftp upload and then provides an appropriate exit code.

    ... ftp upload first ... then ...
    
    # this is FTP download double-check test
    ftp -n -v $FTP_HOST <<SCRIPT >> ${FTPLOGFILE} 2>&1
    quote USER $FTP_USER
    quote PASS $FTP_PASS
    binary
    prompt off
    get $REMOTE_FILE $TEST_FILE
    bye
    SCRIPT
    
    #check to see if the FTP download test succeeded and return appropriate exit code
    if [ -f "$TEST_FILE" ]; then
      echo "... OK FTP download test went fine. Execution may continue"
      exit 0
    else
      echo "... ERROR FTP download test failed. Execution cannot continue"
      exit 1
    fi
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple shell script which looks like this: R --vanilla<myMRjob.R hadoop fs
I have a problem changing a windows batch file into a unix shell script
I have following simple program: import std.stdio; int main(string[] argv) { writeln(Hello, world!); return
I have a simple android app to play videos. I have a main screen
I have two relatively simple codes. One main activity and one intent service. Main
I have a very simple piece of code: #include <stdio.h> #include <glib.h> int main(int
I have created a very simple GUI project in Qt as follows: main: #include
I am using jQuery for a simple website and have a main page 'index.html'
I'm trying to write my first simple mvc app. I have a Main View
I have a bit of sample code that is throwing this warning: main.c: In

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.