vipul chauhan vipul chauhan - 10 months ago 21
Bash Question

Using Shell, How can I read one text file's value and enter it into running crontab as input?

I wanna run one cronjob in which I need to supply input. For this input i have one text file. How can I read that text file data and supply it as input into cronjob?

I am running one cron job with .sh file. which needs input data 2-3 times while running. The data stands into text1.txt, text2.txt, etc.

Now, I want to read data from these text files and insert it as a input in running cronjob. Crontab file execution waits with "expect" command. and it expects some data to go ahead, and that data is residing in a text file.


so if I understand correctly, You run some script as cronjob; so somewhere in that script You can say:

X=`cat file`

or You can add cat file | grep for something to get just one line from Your file

and later use $(X) for expected input