0
import time
start_time = time.time()
for i in range (0, 10000):
    print('openssl rsautl -encrypt -pubin -inkey public.pem -in message.txt -out message_enc.txt')
print("--- %s seconds ---" % (time.time() - start_time))

I want to pass the string within the print method to the Linux command line and run it to get the average encryption time of RSA. I can not seem to figure out how to do this though. I could only find out how to pass arguments from the command line into a Python script.

3
  • import os; os.system('ls -lrt') Commented Sep 19, 2017 at 4:08
  • @itsneo, please don't encourage that. os.system() is deprecated in favor of subprocess, and invoking a shell unnecessarily is bad practice (not only inefficient, but often leads to security bugs). Commented Sep 19, 2017 at 4:08
  • Thanks for linking similar posts. I had no idea to use those keywords. I never want to create duplicate posts. Sometimes I just do not know good keywords to search for. Commented Sep 19, 2017 at 4:16

1 Answer 1

2

You can do this with the subprocess module, which is built-in to Python.

>>> subprocess.call(["ls", "-l"])
0
Sign up to request clarification or add additional context in comments.

1 Comment

See "Answer Well-Asked Questions" in How to Answer. Questions which "have already been asked and answered many times before" should be closed, not answered.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.