Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am launching a ubuntu EC2 instance with my PHP code and passing user data to it. I don't own that instance.. but they provide user level access to it.

Firstly i tried to run a particular job by passing user data, but it did not seem to work.

I made it very simple and send "touch test.txt" as user data. The instance was launched properly but the file was not created as should be i guess.

Am I missing any step? I checked that file was not created using ssh 'ing to the instance. One thing was i was not in root user at instance. Will that effect anything?

header("Content-type: text/plain; charset=utf-8");
require_once '../sdk.class.php';
 // Instantiate the class
$ec2 = new AmazonEC2();
$userdata2="touch hi".".txt";
echo $userdata2;
$response = $ec2->run_instances('ami-5f21e236', 1, 1,
array('KeyName' => 'radix2'),
array('UserData' => $userdata2),
array('InstanceType' => 'm1.small')
share|improve this question

closed as off topic by Skyhawk, freiheit, Shane Madden, voretaq7, MDMarra Feb 5 '12 at 15:03

Questions on Server Fault are expected to relate to server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

Exact duplicate:… – Skyhawk Jan 21 '12 at 22:03

If your UserData does not begin with #! it will be assumed that it is not a script.

You would be wise to read an example of a UserData script to see how you can specify a shell command in the first line of a shell script.

This is assuming that your Ubuntu instance's handling of user data is based on ec2-run-user-data.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.