in Education by
I understand nearly nothing to the functioning of EC2. I created an Amazon Web Service (AWS) account. Then I launched an EC2 instance. And now I would like to execute a Python code in this instance, and I don't know how to proceed. Is it necessary to load the code somewhere in the instance? Or in Amazon's S3 and to link it to the instance? Where is there a guide that explain the usages of instance that are possible? I feel like a man before a flying saucer's dashboard without user's guide. Select the correct answer from above options

1 Answer

0 votes
by
 
Best answer
Using SCP (Secure Copy Protocol), you can transfer files between your local and remote machines. To run python code in your instance, follow the below-mentioned steps: Step 1: Launch an Amazon Linux instance, SSH into it and install Python in it using the following commands: sudo yum update sudo yum install python3.7 Step 2: Open command line terminal on your local machine and run the following command. scp -i path_to_pem_file path_to_python_script username@instance_public_DNS:/path_to_copy For example, following is the command that I used: scp -i C:\Users\intellipaat\Desktop\ohio.pem C:\Users\intellipaat\Desktop\hello.py [email protected]:/home/ec2-user Here, path_to_pem_file : C:\Users\intellipaat\Desktop\ohio.pem path_to_python_script : C:\Users\intellipaat\Desktop\hello.py username: ec2-user instance_public_DNS : ec2-3-19-65-215.us-east-2.compute.amazonaws.com path_to_copy : /home/ec2-user Once you run this SCP command on your cmd, your file will be copied to your instance. Step 3: Go back to your putty terminal and verify that the file has been copied to your instance by running the following command: ls You should see the file there in your instance Step 4: Run this file using the following command: python3 file_name.py And that's it, you will see the output after your run this command

Related questions

0 votes
    I need SSH access to an Amazon EC2 instance running Ubuntu. All I have is the Amazon username and password. Any ideas? Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    I'm currently running an ec2 micro instance and i've been finding that the instance occasionally runs out of memory. ... can be done? Select the correct answer from above options...
asked Feb 1, 2022 in Education by JackTerrance
0 votes
    How can I find out the instance id of an ec2 instance from within the ec2 instance? Select the correct answer from above options...
asked Jan 31, 2022 in Education by JackTerrance
0 votes
    I want to upgrade my Amazon EC2 micro (t1.micro) instance to large. Please help. Select the correct answer from above options...
asked Jan 25, 2022 in Education by JackTerrance
0 votes
    When I reboot an EC2 instance, do I get the initial image again, or is the state of the hard disk before the ... in when I rebooted? Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    Sometimes when trying to launch my t1.micro EC2 instance, it cannot be provisioned and Amazon recommends trying ... existing instance? Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    I've created a new linux instance on Amazon EC2, and as part of that downloaded the .pem file to allow me ... Nov 11:20 amazonec2.pem Select the correct answer from above options...
asked Jan 30, 2022 in Education by JackTerrance
0 votes
    How can I delete instance in Amazon EC2. I have terminated the instance but still it was showing in ... instance gets terminated Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    We have a large ec2 instance running in Asia pacific region. We want to reserve that particular instance.In aws ... out on something Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I want to automate the launch of a set of Linux EC2 instances. Basically, I want to write a script/program that ... in Amazon AWS/EC2? Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I cannot SSH into my instance - Operation timed out. What could be the reasons why, and what can I do to ... because of memory issues. Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    Amazon recently added the wonderful feature of tagging EC2 instances with key-value pairs to make the management of ... the tags? Select the correct answer from above options...
asked Feb 3, 2022 in Education by JackTerrance
0 votes
    I was given AWS Console access to an account with 2 instances running that I cannot shut down (in production). ... into the instances? Select the correct answer from above options...
asked Feb 2, 2022 in Education by JackTerrance
0 votes
    Bit confused here, I have an on-demand instance but do I get charged even when I stop the instance? Select the correct answer from above options...
asked Feb 2, 2022 in Education by JackTerrance
0 votes
    Is it possible to clone an EC2 instance data and all? Select the correct answer from above options...
asked Feb 2, 2022 in Education by JackTerrance
...