Sample code for 30+ languages & platforms
Tcl

Duplicate openssl pkey -in private.pem -pubout -out pubkey.pem

See more OpenSSL Examples

How to output the public part of a private key: Demonstrates how to duplicate this OpenSSL command:
openssl pkey -in private.pem -pubout -out pubkey.pem

Chilkat Tcl Downloads

Tcl

load ./chilkat.dll

set success 0

set pkey [new_CkPrivateKey]

# Load the private key from an PEM file:
set success [CkPrivateKey_LoadPemFile $pkey "private.pem"]
if {$success == 0} then {
    puts [CkPrivateKey_lastErrorText $pkey]
    delete_CkPrivateKey $pkey
    exit
}

set pubKey [new_CkPublicKey]

CkPrivateKey_ToPublicKey $pkey $pubKey

set success [CkPublicKey_SavePemFile $pubKey 0 "pubKey.pem"]
if {$success != 1} then {
    puts [CkPublicKey_lastErrorText $pubKey]
    delete_CkPublicKey $pubKey

    delete_CkPrivateKey $pkey
    delete_CkPublicKey $pubKey
    exit
}

puts "Success."

delete_CkPrivateKey $pkey
delete_CkPublicKey $pubKey