Quantcast
Channel: Azure Virtual Machines forum
Viewing all articles
Browse latest Browse all 12545

Azure Run Command via Rest API

$
0
0

HI,

I have created a VM and a simple python script that opens a local file and print time in there. Then a shell script to run it. This is an experiment for my actual future plan

The shell script look like this

#!/bin/bash

python /home/adminwm/quick-python-time-print.py

echo "Done!"

The python file looks like

#!/usr/bin/env python3

import time

f=open('File-test.txt','a')

f.write(time.ctime(time.time()))

f.close()

It runs ok, as expected.

However, I wanted to run this using Rest API vm run command and the body looks like

{"commandId": "RunShellScript","script": ["sh /home/adminwm/quick-python-test.sh"
  ]
}

I have tried other versions like directly sh quick-python-test.sh and etc/. I get 202 error, but I can see that it has not worked, as the file does not have the time appended to it.

What am I doing wrong?



Viewing all articles
Browse latest Browse all 12545

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>