title: How to pass password as an argument to a shell script
body: <p>I am in process of automating installation of sage through ansible-playbook. In that I need to run two shell scripts.
  Here is how the first shell script look: </p>
  
  <pre><code>#!/bin/bash
  # Creating Sage notebook
  
  dir="/root/.sage/sage_notebook.sagenb"
  screen -S "Sage_Server" sage -c 'notebook(interface="", directory=$dir, port=80, accounts=true)'
  </code></pre>
  
  <p>This is the second shell script's code:</p>
  
  <pre><code>#!/bin/bash
  # Creating Sage inotebook
  
  address=$(hostname --ip-address)
  sage -c "inotebook(interface=" "'$address'" ",port=80,accounts=true)"
  </code></pre>
  
  <p>And this is how the playbook looks:</p>
  
  <pre><code>---
  - hosts: localhost
    remote_user: root
  
    tasks:
     - name : update system
       apt : update_cache=yes    
  
     - name : install m4
       apt : name=m4 state=present
  
     - name : install build-essential
       apt : name=build-essential state=present 
  
     - name : install gcc
       apt : name=gcc state=present
  
     - name : install gfortran
       apt : name=gfortran state=present
  
     - name : install libssl-dev
       apt : name=libssl-dev state=present
  
     - name : install python-software-properties
       apt : name=python-software-properties state=present
  
     - name : add sage ppa repo
       apt_repository: repo='ppa:aims/sagemath'
  
     - name : update system
       apt : update_cache=yes
  
     - name : install dvipng
       apt : name=dvipng state=present
  
     - name : install sage binary
       apt : name=sagemath-upstream-binary state=present
  
     - name : invoke create_sagenb script
       command: /usr/bin/screen -d -m sudo /root/databases-and-datamining-iiith/python-scripts/create_sagenb -i -y
  
     - name : invoke start_sage script
       command: /usr/bin/screen -d -m sudo /root/databases-and-datamining-iiith/python-scripts/start_sage -i -y
  </code></pre>
  
  <p>Now when I run the first script, it asks for a new sage password which could be anything. But I am not able to pass that password from the playbook.
  Still, if I do</p>
  
  <pre><code>ps -ef | grep sh
  </code></pre>
  
  <p>I could see that the scripts are running but the sage service is not running.
  It needs the password in order to start the service.</p>
  
  <p>Could anyone please tell me how can I provide password as an argument to the shell scripts through command.</p>