in reply to
Linux su twice
Seconding
haukex
. You see it as a sequence of commands, but in fact they are nested. You could try something like
system('echo "echo /path/to/file | su - newuser" | sudo su');
[download]
Comment on
Re: Linux su twice
Download
Code
In Section
Seekers of Perl Wisdom