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

asked May 16, 2011 at 12:49
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.

answered May 16, 2011 at 12:55
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())
answered May 16, 2011 at 14:57

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.