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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:40:41+00:00 2026-06-11T08:40:41+00:00

I am trying to automate some of my interactions with git using bash scripts.

  • 0

I am trying to automate some of my interactions with git using bash scripts. To do so I have a script that will ssh and list all the repositories and then clone them. Part of the script is shown here

DIRS=`ssh $u "ls $p"`;
for DIR in $DIRS; do
    echo "ssh://$u$p$DIR"
    echo "git clone ssh://$u$p$DIR";  
    git clone ssh://$u$p$DIR
done

Example arguments are

-u user@host

and

-p /cygdrive/c/Documents\ and\ Settings/somePath

This work fine for filepaths with spaces in their names up until the git clone part where it throws an error about too many spaces. If I copy and pasted the part echoed by

echo "git clone ssh://$u$p$DIR";

then it clones just fine. I have tried to surround this in quotes but it throws an error

does not appear to be a git repository

What am I doing wrong?

Edit 1

The errors when using git clone "ssh://$u$p$DIR" is

fatal: '/cygdrive/c/Documents\ and\ Settings/somePath/repo1' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
  • 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-11T08:40:42+00:00Added an answer on June 11, 2026 at 8:40 am

    I’ve used information from Gilles’s and Antak’s answer to find a solution as well as some other posts on running ssh on a remote machine and using variables in a bash heredoc.

    As suggested by Gilles I avoided using ls and I’ve used Antak’s suggestion of using IFS=$'\n'
    to avoid multiple arguments from spaces and split arguments on line breaks.

    The final code I’ve settled on is

    DIRS=`ssh "$u" << ENDSSH
        cd "$p"
        eval 'for file in *; do echo \\$file; done'
    ENDSSH`
    
    IFS=$'\n'
    for DIR in $DIRS;
        do
        echo "ssh://$u$p/$DIR"
    done
    unset IFS 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some SQL scripts that I'm trying to automate. In the past I
I am trying to automate some manual labor, using a bash script. Basically I
I have some tasks on a site in php using nginx that I'm trying
trying to automate using perl scripts on windows server using MediaWiki::Bot and Mediawiki::API taken
I am trying to automate my trigger process so that I don't have to
I'm trying to automate menu picks using Microsoft UI Automation. The application that I'm
I'm trying to automate some processes using Robot and it seems certain keycodes (only
I am trying to automate JavaScript forms/pages in IE7 using VBA. I have already
I'm trying to convert some XML so that iso8879 entity strings will appear in
I'm trying to automate some stuff in SVN, and part of that is copying

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.