how to attach existing images(image field) to node in drupal 7?
can u provide me an example of how to upload image programmatically
  provided I have an image url on the public path in D7


This should do the trick

$node  = node_load($nid);     
$image = file_get_contents('public://images/folder_name/image_name.jpg');
$file  = file_save_data($image, 'public://images/folder_name/image_name.jpg', FILE_EXISTS_REPLACE);
$node-&gt;field_image[LANGUAGE_NONE][0]['fid'] = $file-&gt;fid;
node_save($node);