0

I have this in my bash script

for FOLDERNAME in `\ls -1 /home/`
do
if [ ! -d /backups/home/${date} ]; then
mkdir /backups/home/${date}
chmod 777 /backups/home/${date}
/bin/chgrp ${FOLDERNAME} /backups/home/${FOLDERNAME}
usermod -a -G ${FOLDERNAME} john
fi

how can i convert that to python code

3
  • 1
    Step by step is the easiest way. Commented May 16, 2011 at 12:59
  • Show us what you've written thus far and any errors you are getting and we will help with that. We can't just 'do it for you' Commented May 16, 2011 at 13:31
  • i am reading the os module and i will post back when done . thanks Commented May 16, 2011 at 13:50

2 Answers 2

2

Most of it can be done using the "os" module : I advise you to have a look at the doc of this module, try, and if you have issue, ask for relevant questions.

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

Comments

0

While not being very familiar with Linux commands, this code should help you in attaining your final goal.

import shutil, datetime
shutil.copytree('/home/', '/backups/home/' + datetime.date.today().isoformat())

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.