Dear All, I am executing my R script from PHP using the shell_exec. $return = shell_exec("/usr/bin/R --slave --args ".$Domain.",".$Gender." < /var/www/html/trends/newTrend.R"); In newTrend.R, I am plotting graph and save in pdf file using the below code. It will create a pdf file with two line. pdf(file="/var/www/html/trends/bmtrend.pdf", height=7.5, width=10.5) g_range <- range(0,index , ReqDataindex) plot(index, type="o", col="blue", ylim=g_range,axes=FALSE, ann=FALSE) axis(1, at=1:7, lab=c(1:daycount)) axis(2, las=1, at=25*0:g_range[2]) box() lines(ReqDataindex, type="o", pch=22, lty=2, col="red") Now what I want do is: I want to execute shell_exec() second time with different argument and I want to add one more line to existing (bmtrend.pdf) file. I mean if the bmtrend.pdf file does not exist, my script has to create the file. If the bmtrend.pdf file is already exist, I want to append new line in existing file. any help would be greatly appreciated. Thanks for you time. Mohan L [[alternative HTML version deleted]]