# Set counter to a value written in another file

I got a file 'month.tex' containing only an integer. I want to set a counter to this integer and tried

\newcounter{billmonth}
\setcounter{billmonth}{\input{month.tex}}


This isn't working as the compiler sais

<to be read again>
\let
l.42 \setcounter{billmonth}{\input{month.tex}}


Does anybode have an idea how to deal with this? Thanks!

Why do I have a file containing only this integer? I use a bash script for compiling where you can pass an argument. This argument needs to find its way inside of my latex document and it was the best way i could think of.

• – Andrew Oct 28 '17 at 13:19

The readarray package can help, with its \readdef{<filename>}\macro syntax.

\documentclass{article}
\usepackage{filecontents}% this is only to show that it works
\begin{filecontents*}{monthfile}
3
\end{filecontents*}