Bash script

Hello. I would like to write a bash script (.sh) which opens a ntuple with root, plots some histograms from it, saves them and closes root. The idea will be something like

root -l file.root
ntuple->Draw(“whatever”)
c1->SaveAs(“whatever.eps”)
.q

The problem is that if i write those commands directly in the sh script, it will only execute the first one (will open file.root and stay waiting until i do something in the root[0] prompt). Is there any way to do this?

Thank you

Hi,

Just use a here document:

[code]#!/bin/bash

root -l file.root << EOF
ntuple->Draw(“whatever”)
c1->SaveAs(“whatever.eps”)
EOF[/code]

Cheers,
Philippe.

1 Like