How to create a transaction with a custom script?
I would suggest using Python to accomplish this. pybitcointools have what you need to be able to deserialize a hex transaction to JSON, and manipulate that and then serialize again to be able to sign and broadcast via support for blockchain.info.

This example will rebuild the standard script from the ground up:

&gt;&gt;&gt; opdup = 0x76
&gt;&gt;&gt; ophash160 = 0xA9
&gt;&gt;&gt; push20 = 0x14
&gt;&gt;&gt; opeqver = 0x88
&gt;&gt;&gt; opchecksig = 0xAC
&gt;&gt;&gt; pubkeyhash = 0x2dbde30815faee5bf221d6688ebad7e12f7b2b1a


We are going to append hex values by moving them bitwise.


OP_DUP OP_HASH160 2dbde30815faee5bf221d6688ebad7e12f7b2b1a OP_EQUALVERIFY OP_CHECKSIG
This is the hex we want 76a9142dbde30815faee5bf221d6688ebad7e12f7b2b1a88ac


This is one way of doing it

&gt;&gt;&gt; quickfix = 0xff
&gt;&gt;&gt; asm = quickfix
&gt;&gt;&gt; asm = asm &lt;&lt; 8 | opdup
&gt;&gt;&gt; asm = asm &lt;&lt; 8 | ophash160
&gt;&gt;&gt; asm = asm &lt;&lt; 8 | push20
&gt;&gt;&gt; asm = asm &lt;&lt; 8*20 | pubkeyhash
&gt;&gt;&gt; asm = asm &lt;&lt; 8 | opeqver
&gt;&gt;&gt; asm = asm &lt;&lt; 8 | opchecksig


Ant then to check if its the same:

&gt;&gt;&gt; almost = hex(asm)
&gt;&gt;&gt; ready = almost.partition("0xff")[2]
&gt;&gt;&gt; print(ready)


Hope this is what you are after :-)