Syncronous wait function in Shell