Hi Yessine,
Yes, you can do it by script:
1- Get the port handle of both blocks
portHandles1 = get_param('model/block1','PortHandles');
portHandles2 = get_param('model/block2','PortHandles');
2- Add a line connecting the outport of one block to the outport of the other block
add_line('model',portHandles1.Outport,portHandles2.Inport);