You can't. You would have to combine those operations into a single command, but even then su will not allow it; to switch to the user "root" you MUST be a tty. This is a security measure meant for your protection.
You need to write a shell script and make it run suid root (or make your target program do so). It's Unix manual time.