2

I've got a simple script to create directories on a remote server using SSH:

    while read memberName; do
        ssh ${serverPath} "mkdir -p ${filePath}"
        wait
    done < sqlRes.txt

(I've simplified it a bit - those variables do exist and are fine).

If I make each SSH call a background job (with &), it works better but not completely (it should create 200 directories, only doing 170, for example).

As it is, it exits the loop after the first entry in sqlRes.txt with no error message and a successful return status.

I've tried sleep and wait commands but neither help.

I'm guessing there's maybe a limit of sub-shells but I thought 'wait' should ensure each one is closed before I try the next?

Any ideas, please?

FYI - ksh in Linux RedHat

1 Answer 1

2

Sorry - found the answer after some more searching (ssh is interactive and takes all the input. Changed to 'ssh -n' and all ok).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.