Note that there are some explanatory texts on larger screens.

plurals
  1. POScripting Python for Linux commands
    primarykey
    data
    text
    <p>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.</p> <p>Here is my function for running the script:</p> <pre><code>def runScript(): # Cannot concatenate 'str' and 'list' objects #script = rdiff + rdiffArgs script = rdiff + ' ' + rdiffVerbosity + ' ' + rdiffStatistics \ + ' ' + clientName + '@' + clientHost + '::' + clientDir \ + ' ' + serverDir os.system(script) </code></pre> <p>What I originally thought would be neat was to add all the variables into a list, so I could just run say </p> <pre><code>script = rdiff + rdiffArgs </code></pre> <p>Is there a better way to do this without all the space concatenation?</p> <p>Thanks for your assistance</p> <p>EDIT: Let me post the whole script so far. I wasn't very clear and I really appreciate your help and patience</p> <pre><code> #!/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 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload