Menu

Environment variables in paths?

Help
2025-12-31
2026-01-13
  • Clifford Banes

    Clifford Banes - 2025-12-31

    I'm trying to use Grsync on Linux Mint Debian Edition 7 to backup/sync between several drives. I've encountered a major roadblock in the form of environment variables; I want to be able to use the same sessions for multiple users and locations, but when I put those variables in Source and Destination paths (e.g., "/home/$USER/" or "home/%USER%/"), Grsync gives me errors like "change_dir "/home/$USER" failed: No such file or directory". (For the record, I'm using $USER for this example because it's simple and universal - I need to use other variables, some of which I'm creating, so any method that would only get me to the home directory wouldn't suffice.)

    In Terminal, rsync can interpret variables fine. But it's beyond my skills and time to figure out how to use the command line to do everything else Grsync does that I need. I've tried.

    FreeFileSync can handle variables, but its roadblock is difficulties with modification times on copied files. This is actually my second go at Grsync because it supposedly doesn't have that problem.

    Am I missing something? Is there some way to use environment variables in Grsync, or am I out of luck?

    Thank you.

     
    • Piero Orsoni

      Piero Orsoni - 2026-01-02

      Dear Clifford,

      The reason why running rsync from a shell works is because it's the shell
      itself expanding the variables.
      Normally, grsync runs rsync without passing through a shell, that's why
      there's no expansion in that case.
      I'm planning to add a session checkbox to "pass command through a shell"
      for that reason; meanwhile, you can do the same by prepending the command
      with "sh -c", or something like that.

      Have a nice day!

      On Wed, 31 Dec 2025 at 23:52, Clifford Banes cliffordbanes@users.sourceforge.net wrote:

      I'm trying to use Grsync on Linux Mint Debian Edition 7 to backup/sync
      between several drives. I've encountered a major roadblock in the form of
      environment variables; I want to be able to use the same sessions for
      multiple users and locations, but when I put those variables in Source and
      Destination paths (e.g., "/home/$USER/" or "home/%USER%/"), Grsync gives me
      errors like "change_dir "/home/$USER" failed: No such file or directory".
      (For the record, I'm using $USER for this example because it's simple and
      universal - I need to use other variables, some of which I'm creating, so
      any method that would only get me to the home directory wouldn't suffice.)

      In Terminal, rsync can interpret variables fine. But it's beyond my skills
      and time to figure out how to use the command line to do everything else
      Grsync does that I need. I've tried.

      FreeFileSync can handle variables, but its roadblock is difficulties with
      modification times on copied files. This is actually my second go at Grsync
      because it supposedly doesn't have that problem.

      Am I missing something? Is there some way to use environment variables in
      Grsync, or am I out of luck?

      Thank you.

      Environment variables in paths?
      https://sourceforge.net/p/grsync/discussion/1085771/thread/7b5c7c9a2d/?limit=25#2917


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/grsync/discussion/1085771/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

      --
      Piero Orsoni
      orsoni@gmail.com

       
      • Clifford Banes

        Clifford Banes - 2026-01-02

        Thank you for the quick response, Piero! Can this prepending be done in the Grsync app, or does it need to be through the command line? I tried putting sh -c in the "Extra options > Execute this command before rsync" field, and I got this error:

        ** Launching BEFORE command:
        sh -c
        Error launching command!

        I also tried bash -c, to the same effect. If it needs to be through the command line, then it's redundant and I'm back to square one in that regard.

         
        • Clifford Banes

          Clifford Banes - 2026-01-02

          And for what it's worth, putting just sh or bash in that field doesn't throw an error, but neither does it have any effect on expanding variables.

          I feel like I should mention, if it isn't already very obvious, that I'm new to Linux and not a programmer. I'm coming from Windows, and my goal is to set up Linux in such a way that I can deal with it with the minimum possible command-line work in the future. I'm starting to feel like I was spoiled by SyncBack, which presents a very robust set of capabilities graphically that I ended up making use of in complex ways over the years. Recreating something like that in Linux has been a real challenge. I appreciate your patience with my ignorance.

           
          • Piero Orsoni

            Piero Orsoni - 2026-01-13

            Don't worry: I don't remember how I used to do it years ago 🤣
            Maybe someone else recalls?

            Anyway, having the command line passed through a shell for expansion is on my todo list.
            I just need to make sure there are no possible security issues in the feature.

             
  • Piero Orsoni

    Piero Orsoni - 2026-01-02

    Hi Clifford,

    The reason why running rsync from a shell works is because it's the shell itself expanding the variables.
    Normally, grsync runs rsync without passing through a shell, that's why there's no expansion in that case.
    I'm planning to add a session checkbox to "pass command through a shell" for that reason; meanwhile, you can do the same by prepending the command with "sh -c", or something like that.

    Have a nice day!

     

Log in to post a comment.