#!/usr/bin/perl
use CGI qw(param);

$home = "/usr/local/e-cron";
$jobnet = param("jobnet");
$project = param("project");
$jobname = param("jobname");
$execute_command = param("execute_command");
$recovery_command = param("recovery_command");
$exclusive_resource = param("exclusive_resource");
$tmp_file = "/tmp/${project}${jobnet}${jobname}.tmp";

# update job
open(JOBPROF,">$tmp_file");
print JOBPROF "EXECUTE_COMMAND\=\"$execute_command\"" ;
print JOBPROF "\n" ;
print JOBPROF "RECOVERY_COMMAND\=\"$recovery_command\"" ;
print JOBPROF "\n" ;
print JOBPROF "EXCLUSIVE_RESOURCE\=\"$exclusive_resource\"" ;
print JOBPROF "\n" ;
close(JOBPROF);

system("sudo -u ejobmgr cp $tmp_file $home/project/$project/$jobnet/$jobname");
system("sudo -u ejobmgr chmod 755 $home/project/$project/$jobnet/$jobname");

print "Content-type: text/html\n\n";
###############contents insert#########
system("cat ../elements/header");
print "<h4>job has successfully updated. please distribute it</h4>";
print "&nbsp;&nbsp;&nbsp;<a href=\"./set_jobnet_form.cgi?${project},${jobnet}\">Back to Jbonet and Distriute to Servers !</a>";
print "<br></br>";

system("rm $tmp_file");
