How do I execute a shell command from Ipython/Jupyter notebook passing the value of a python string variable as a string in the bash argument like in this example:
sp_name = 'littleGuy' #the variable
sp_details = !az ad app list --filter "DisplayName eq '$sp_name'" #the shell command
I've tried using $sp_name
alone, ${sp_name}
, {sp_name}
etc as outlined in this related question, but none have worked.
The kicker here is the variable name needs to be quoted as a string in the shell command.
EDIT1:
@manu190466. I was judging from the string output that your solution worked. It appears for some reason it does not in practice. I wonder if az ad app list
URL encodes the query or something...?
Thoughts?