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 7163577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:55:34+00:00 2026-05-28T13:55:34+00:00

I have two source files created in unix folder say file1.dat and file2.dat. I

  • 0

I have two source files created in unix folder say file1.dat and file2.dat.

I need to send the files to mainframe using SCP.

The unix script I wrote is as below:

if [[ -f $MY_DIR/$SOURCE1 ] -a [ -f $MY_DIR/$SOURCE2 ]]; then

       scp -P 2222 $MY_DIR/$SOURCE1 $MFDESTINATION1
       if [ $? -ne 0 ]; then
           ftp_status='100'
           $LOG_DIR/my_log $0 "(SCP FOR $SOURCE1) ended in ERROR"
           exit 255

       else         
          scp -P 2222 $MY_DIR/$SOURCE2 $MFDESTINATION2
          if [ $? -ne 0 ]; then
            ftp_status='100'
            $LOG_DIR/my_log $0 "(SCP FOR $SOURCE2) ended in ERROR"
            exit 255
          fi
      fi
fi

The logic works fine for file1 i.e. if file1 transfer results in error, do not transfer file2.

But if file1 transfer succeeds, file2 transfer gets initiated. If that fails, file1 is already in MF.

I dont want that. I want to send either both the files or none of them.

How to achieve that ?

I know last option is to delete file1 in MF if file2 transfer fails. But is there any other way ?

Thanks for reading!

  • 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-05-28T13:55:34+00:00Added an answer on May 28, 2026 at 1:55 pm

    What I would do is transfer the files to a temporary location on the same filesystem where the final files should be (or with a temporary name that won’t be picked up by the remote service), and rename the files if both transfers were successful. The rename should never fail on the same filesystem if you make sure the filenames are available.

    cheers,
    mitch

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say your program is composed of two source files (main.c and auxiliary.c) and two
Suppose I have two lists that holds the list of source file names and
I have two large source trees. One of them has some out of date
I have two tables: a source table and a target table. The target table
I have a class with two constructors that look like this: public MyClass(SomeOtherClass source)
I have a Grails 2.0.0 project that was created using grails create-app . In
I've just begun learning Unix and have so far encountered two elementary though difficult
My application currently installs documents and other files to two folders using lines like:
Let's say you have two products A and B which are both developed, tested
I have a search textbox and two image buttons on a page I created

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.