Answers: <p>First option using aws &quot;CloudShell&quot; service (available only in specific region).</p>
  <p>Alternately, you can execute shell script using AWS Systems Manager &gt; Run Command &gt; Run a command, Select the type of command that you want to run &amp; Search by keyword
  &quot; AWS-RunShellScript &quot; (Linux platform only).</p>
  <p>In Command Parameters, specify a shell script or a command to run.</p>
  <p>PS : For both Windows &amp; Linux platform, search by keyword &quot; AWS-RunPowerShellScript &quot;</p>
  
Answers: CC BY-SA 4.0
Answers: 2022-08-30T07:10:55.790Z
Answers: 2022-10-06T12:54:36.533Z
Answers: 2022-10-06T12:54:36.533Z
Answers: RaviPrasad S
Answers: <p>You can write a bash or shell script in SSM run command and execute it in a linux ec2 instance using the following command:</p>
  <p>aws ssm run-command --document-name &quot;MyShellScript&quot; --instance-ids &quot;i-1234567890&quot; --parameters &quot;MyScriptParameter=Value&quot;</p>
  <p>This will execute the &quot;MyShellScript&quot; script on the instance with ID &quot;i-1234567890&quot; and pass in the parameter &quot;MyScriptParameter&quot; with value &quot;Value&quot;.</p>
  
Answers: CC BY-SA 4.0
Answers: 2022-10-07T13:06:03.087Z
Answers: 2022-10-07T13:06:03.087Z
Answers: Rahul Sherkar
Body: <p>I want to run the bash or shell script in Linux using the SSM run command. But I don't want to write it on the Linux server and execute it remotely using the SSM command. I want to write a script in the run command itself.</p>
  <p>Is there any way to run a script from the AWS console? Apart from the run command is there any other way to run the whole script?</p>
  <p>I am referring to the multiline script not only one command.</p>
  
Tags: <amazon-web-services><amazon-ssm>
Title: How to write bash or shell script in SSM run command and execute in linux ec2 instance?
UserDisplayName: jayaprakash R
ThreadText: # How to write bash or shell script in SSM run command and execute in linux ec2 instance?
  
  (Asked by: username_0 on 2022-07-01)
  
  I want to run the bash or shell script in Linux using the SSM run command. But I don't want to write it on the Linux server and execute it remotely using the SSM command. I want to write a script in the run command itself.
  
  Is there any way to run a script from the AWS console? Apart from the run command is there any other way to run the whole script?
  
  I am referring to the multiline script not only one command.
  
  **Tags:** amazon-web-services, amazon-ssm
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2022-08-30. Score: 0
  
  First option using aws "CloudShell" service (available only in specific region).
  
  Alternately, you can execute shell script using AWS Systems Manager > Run Command > Run a command, Select the type of command that you want to run & Search by keyword
  " AWS-RunShellScript " (Linux platform only).
  
  In Command Parameters, specify a shell script or a command to run.
  
  PS : For both Windows & Linux platform, search by keyword " AWS-RunPowerShellScript "
  
  
  ---
  
  ### Answer by username_2 on 2022-10-07. Score: -1
  
  You can write a bash or shell script in SSM run command and execute it in a linux ec2 instance using the following command:
  
  aws ssm run-command --document-name "MyShellScript" --instance-ids "i-1234567890" --parameters "MyScriptParameter=Value"
  
  This will execute the "MyShellScript" script on the instance with ID "i-1234567890" and pass in the parameter "MyScriptParameter" with value "Value".
  
  
  ---
  
  