0
how to call python variables inside bash commands or can I do that?
I am trying to list cronjobs of all users user_file = open('/root/pys/userdomains', 'r') for line in user_file: print line splitted_line = line.split(': ') print splitted_line user_cron = splitted_line[1].split() print user_cron print "crons for", user_cron, "is", CronTab(user=user_cron) On last line, can I use os.system('crontab -l -u user_cron') to get similar result. I know there is CronTab option, but in similar cases can I use python variables inside bash commands
1 Respuesta
+ 1
Sure you can use variables inside command.
import os
ip_add = '127.0.0.1'
#use one of next examples
os.system('ping %s' % ip_add)
os.system('ping {}'.format(ip_add))
os.system('ping ' + str(ip_add))