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

  • Home
  • SEARCH
  • 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 545201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:44:10+00:00 2026-05-13T10:44:10+00:00

I have a question. I have been really trying to learn Python. For a

  • 0

I have a question. I have been really trying to learn Python. For a project, I want to make an ncurses GUI for my backup server. My backup server runs rdiff-backup, and I want to have the ncurses take in variable names and plug them into my script. I have been trying to do a lot of reading so I don’t ask dumb questions.

Here is my function for running the script:

def runScript():
# Cannot concatenate 'str' and 'list' objects
#script = rdiff + rdiffArgs

script = rdiff + ' ' + rdiffVerbosity + ' ' + rdiffStatistics \
         + ' ' + clientName + '@' + clientHost + '::' + clientDir \
         + ' ' + serverDir

os.system(script)

What I originally thought would be neat was to add all the variables into a list, so I could just run say

script = rdiff + rdiffArgs

Is there a better way to do this without all the space concatenation?

Thanks for your assistance

EDIT: Let me post the whole script so far. I wasn’t very clear and I really appreciate your help and patience

  #!/usr/bin/env python



import os
import smtplib


# Global variables
rdiff = '/usr/bin/rdiff-backup'
rdiffVerbosity = '-v5'
rdiffStatistics = '--print-statistics'
emailSmtp = 'smtp.gmail.com'
smtpPort = '465'
emailUsername = 'reports'
emailPassword = '3kc9dl'
emailTo = 'user@domain.com'
emailFrom = 'internal@domain.com'
serverName = 'root'
serverHost = 'SV-Datasafe'
serverDir = '/srv/backup/SV-Samba01'
clientName = 'root'
clientHost = 'SV-Samba01'
clientDir = '/srv'
rdiffArgs = rdiffArgs = [rdiffVerbosity, rdiffStatistics, \
                         clientName + '@' + clientHost + '::' \
                         +clientDir + ' ' + serverDir]
time = ''
dateStamp = datetime.now()



def sendEmail():
    subject = dateStamp + clientName
    body = clientDir + ' on ' + clientHost + ' backed up to ' + serverName + \
           ' in the directory ' + serverDir + ' on ' + dateStamp
    message = """\
    From: %s
    To: %s
    Subject: %s
    %s
    """ % (emailFrom, emailTo, subject, body)


    deliverEmail = smtplib.SMTP(emailSmtp, port=smtpPort)
    deliverEmail.login(emailUsername, emailPassword)

def runScript():
    # Cannot concatenate 'str' and 'list' objects
    #script = rdiff + rdiffArgs

    script = rdiff + ' ' + rdiffVerbosity + ' ' + rdiffStatistics \
             + ' ' + clientName + '@' + clientHost + '::' + clientDir \
             + ' ' + serverDir

    os.system(script)

    # TODO:: Logging
  • 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-13T10:44:11+00:00Added an answer on May 13, 2026 at 10:44 am

    you can use format specifiers

    def runScript():
        script = "%s %s %s@%s %s::%s %s" %(rdiff,rdiffVerbosity,rdiffStatistics,clientName,clientHost,clientDir,serverDir)    
        os.system(script)
    

    or say your rdiffArgs is already in a list

    rdiffArgs = [rdiffVerbosity,rdiffStatistics,clientName,clientHost,clientDir,serverDir]
    

    you can join them with a space

    rdiffArgs = ' '.join(rdiffArgs)
    

    lastly, just so you might want to know, you can import rdiff in your script , since rdiff-backup is written in Python

    from rdiff_backup.Main import Main as backup
    task=['/etc', '/tmp/backup']
    backup(task)
    

    the above backs up /etc/ to /tmp/backup. That way, you don’t have to make system call to rdiff-backup. Of course, this is up to you. making system call is sometimes easier

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

Sidebar

Ask A Question

Stats

  • Questions 297k
  • Answers 297k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer No, you cannot reverse SHA-1, that is exactly why it… May 13, 2026 at 7:21 pm
  • Editorial Team
    Editorial Team added an answer It depends on what your rule for italic headings is.… May 13, 2026 at 7:21 pm
  • Editorial Team
    Editorial Team added an answer Trying to offer more help since the initial solution didn't… May 13, 2026 at 7:21 pm

Related Questions

I'm trying to implement something like Google suggest on a website I am building
Let me start off by saying Im VERY new to iphone development, but Im
This is similar to a question I asked a couple of days ago. However,
I'm looking for a simple solution using Python to store data as a flat
I know there have been a few threads on this before, but I have

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.