vipul chauhan vipul chauhan - 2 years ago 73
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.

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download