By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,034 Members | 2,000 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,034 IT Pros & Developers. It's quick & easy.

How to execute a Shell Script in python Codes

P: 1
Hi,

I have a python script which creates a csv file using following method
Expand|Select|Wrap|Line Numbers
  1.  def printOutInformation(self):
  2.         if self.orderby == 'r':
  3.             self.iplist.sort(cmp=self.RealtimeComparison)
  4.         elif self.orderby == 'p':
  5.             self.iplist.sort(cmp=self.ProcessingtimeComparison)
  6.         # by default the order will just be the order that the IPs were in the reasoning log
  7.         if csvoutput:
  8.             csvfile = open(self.csvfile, 'w')
  9.             csvfile.write("IP Address,Total Time Elapsed,Pipeline Processing Time,Start Time,End Time\n")
  10.             for list in self.iplist:
  11.                 ip, realtime, processingtime, starttimestamp, endtimestamp = list
  12.                 csvfile.write("%s,%s,%s,%s,%s\n" % (ip, realtime, processingtime, starttimestamp.isoformat(), endtimestamp.isoformat()))
  13.             csvfile.close()
I want to run the additional shell script once the above csv file has been generated.

Any Hints

Thanks

Mehdi
Jan 2 '07 #1
Share this Question
Share on Google+
2 Replies


P: 8
Expand|Select|Wrap|Line Numbers
  1. import os
  2. cwd = os.getcwd() # this will get the path you are current in if you need it
  3. os.system('sh script.sh')
Jan 2 '07 #2

bartonc
Expert 5K+
P: 6,596
Hi,

I have a python script which creates a csv file using following method
Expand|Select|Wrap|Line Numbers
  1.  def printOutInformation(self):
  2.         if self.orderby == 'r':
  3.             self.iplist.sort(cmp=self.RealtimeComparison)
  4.         elif self.orderby == 'p':
  5.             self.iplist.sort(cmp=self.ProcessingtimeComparison)
  6.         # by default the order will just be the order that the IPs were in the reasoning log
  7.         if csvoutput:
  8.             csvfile = open(self.csvfile, 'w')
  9.             csvfile.write("IP Address,Total Time Elapsed,Pipeline Processing Time,Start Time,End Time\n")
  10.             for list in self.iplist:
  11.                 ip, realtime, processingtime, starttimestamp, endtimestamp = list
  12.                 csvfile.write("%s,%s,%s,%s,%s\n" % (ip, realtime, processingtime, starttimestamp.isoformat(), endtimestamp.isoformat()))
  13.             csvfile.close()
I want to run the additional shell script once the above csv file has been generated.

Any Hints

Thanks

Mehdi
Hello, Mehdi. I've added CODE tags to your post to make it readable. You will learn how to do this as we go along. Instructions are in "Posting Guidelines" in several places on this forum. Also, We need to know which operating system you are on, in order to give the correct information.
Jan 2 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.