Getting the slug into a variable, how to echo that variable

Try this:

$post = get_post($post_id); 
$slug = $post->post_name;