-4

When I type this into the terminal I get the output right away. I would like to make this into a variable and use it on my code

python -c 'import crypt; print crypt.crypt("MyPassword", "$6$LsCK1WmouFiO9AT/$")'

I have tried something like this

 Password = python -c 'import crypt; print crypt.crypt("MyPassword", "$6$LsCK1WmouFiO9AT/$")'
Red Virus
  • 1,633
  • 3
  • 25
  • 34
  • 2
    Variable for what? What kind of code is "your code"? –  Jul 12 '18 at 10:56
  • 1
    do you want to assign this value to a variable in a bash script? or python ? – Murali Jul 12 '18 at 11:02
  • @Murali yes I'm using the code inside ,shell file. The return value from `python -c 'import crypt; print crypt.crypt("MyPassword", "$6$LsCK1WmouFiO9AT/$")'` should be in a variable. – Red Virus Jul 12 '18 at 11:36

1 Answers1

1

If by 'variable' you mean a variable in Python code, just put your code into a Python script file, for example mycrypt.py.

import crypt

mypassword = crypt.crypt("MyPassword", "$6$LsCK1WmouFiO9AT/$")

The variable mypassword can then be used later in this Python script.

Edit: In bash assign the result of the python execution to a variable

$ password=$(python -c 'import crypt; print crypt.crypt("MyPassword", "$6$LsCK1WmouFiO9AT/$")')