Access notebooks parameters from a bash cell

jollymon
New Contributor II

How can I access a notebook parameter from a bash cell (%sh)? For python I use dbutils.widgets.get('param'), and for SQL I can use :param. Is there a something similar for bash?

szymon_dybczak
Esteemed Contributor III

Hi @jollymon ,

I believe there is no direct way to do this. But maybe there are some workarounds though. You can try to read widgets in python and set those values as envrionment variables. Then you can use shell to read that variables. Something like below (except in python try to read widget value)

%python
import os
l =['A','B','C','D']
os.environ['LIST']=' '.join(l)print(os.getenv('LIST'))
%sh
for i in $LIST
do
  echo $i
done

 

View solution in original post

That works. I suppose that's what I'll need to do then.

Thanks.

szymon_dybczak
Esteemed Contributor III

No problem, glad that it worked for you