I had a week long power outage, and as an emergency measure, I considered doing this to run the furnace blower (gas furnace). Instead, I wired some romex into the furnace junction box (disconnecting the furnace from the house) with the other end wired to a male connector. I then plugged the romex 'cord' into a 12 AWG extension cord and connected it to the generator in the backyard. This worked to power the furnace and although we were in the dark, we were warm. What you describe will 'work' but has many dangers. Just install a transfer switch, is my advice.