How to run python script on google cloud using android studio? - python

I want to run python script on google cloud using android studio
ex: I have an android application which contain button and google cloud VM instance which has a python script.
I want when click button, the script is run and output send to storage.
how I can do that ?

I suppose you're running a linux-based distribution as your operating system. I think that you could do that by sending a command to the VM via ssh, and by using pipes in linux you could direct the output to a specific file.
Let's say you have your python script named script_one.py
With this command python3 script_one.py > output.txt you basically run the script and the output of it is stored in the file output.txt in the same directory where the python script is, now of course you could use absolute or relative path to redirect your output to another place.
Depending on the language you're developing your application in, this can be implemented in different ways.

Related

How to always run specific python script on windows server manager 2016

i am new to the community and new in using servers and could use some help.
I am trying to setup an automatic JSON parser to another server using http post calls. The idea is as follows:
I manually put JSON files into a folder Input on the server
A python script that is always running on the server reads the files located within the folder
It reads the JSON files, posts all objects to another server, and moves the files to a "Processed" folder one file at a time.
I have been given a Windows Server, with Windows Server Manager 2016, and have managed to do the following:
installed python 3.8.2. on the windows server
able to run a python script using powershell
Installed NSSM to create a windows service
Now the windows server manager says i cannot resume or start the service that i tried to install via NSSM.
I am very new to servers, as well as python itself. Can somebody help me to get a python script running 24/7 on a windows server with windows server manager 2016?
Edit:
I managed to create a python script that can read files, upload them and move them to a processed folder, but i still have to run it by myself while i want it to always run on the server

run python script on local machine stored on remote server

I would like to execute a python script stored on a remote server on a local machine. This is so I can keep the code for the script on the server without the user having a copy. Is this possible using python?
I am basically trying to secure the code, possibly behind a username and/or password so that way I can easily update the codebase. (Much like using ssh - but the python script is executed on the local machine instead of the server.)
Edit:
Using curl and process substitution this may be achievable:
execute bash script from URL
so that to execute the python script the command is:
python <(curl "http://example.com/test.py" -s -N)
curl also supports password protection which is ideal.
When I execute the script the root path for the script is /dev/fd. When I navigate to this directory and list directory only contains numbers.
Using the above command as an example, is the script downloaded? (and where to). I notice that if I execute the script in a directory such as Desktop it is not downloaded to that location (the working directory).
You can compile the Python code into compiled Python .pyc files and distribute these files, though the local machine should have the same Python environment as the server.
However it is also not impossible for this code to be decompiled.
https://python-compiler.com/post/how-to-distribute-python-program

Is there a way run a python script on another server?

I have a Djnago web application on IIS 6 on one server. Is there a way that from this website I call another python script that is on another server in such a way that that script just run itself there?
Calling or Runnig that script in the usual way as internet says, is not working.
I always get the error of os.getcwd() and it also doesn't allow to change that directory.
I just want to run that python script there on that server from this server.
Can anyone help?
Normally, I would recommend using a framework like fabric or winrm if you want to run a python script on another server. Those frameworks use ssh or windows remoting functionality, respectively, to allow a python program to execute other commands (including python scripts) on other systems. If the target machine is a windows machine, be forewarned that you can run into all sorts of UAC issues doing normal operations.

Problems installing Cloud SQL Proxy on Windows 64-bit

I'm trying to install Cloud SQL Proxy for Google Cloud Platform on my Windows 10 64 bit OS, so I can use Python scripts to dump data into SQL. I'm following this guide to get it set up.
I created a project and a Google Cloud SQL instance from the Console without any issues, and it shows up in the SDK shell without any problems. After downloading the proxy installer and installing it, a dialog window opens up and then closes before I can read it.
When I go to the Google Cloud SDK shell and try to start the Cloud SQL Proxy with: cloud_sql_proxy.exe -instances="[MyInstanceConnectionName]"=tcp:3306
No matter how many times I try, it throws the error "Cloud Sql Proxy is not recognized as an internal or external command, operable program or batch file." I already tried re-downloading and re-executing the file but it still won't work.
I have Python 3.6 with Anaconda and Google Cloud SDK shell installed on Windows 10 64-bit.
When you download the cloud_sql_proxy file make sure to rename it as per instructions in the how to guide. Also make sure you save it in the root directory of where you will run it from. E.g. If you are running the command from C:/users/desktop>.\cloud_sql_proxy.exe -instances="[YOUR_INSTANCE_CONNECTION_NAME]"=tcp:3306 then the cloud_Sql_proxy file must be located in the root C drive.
Open PowerShell or whatever terminal you use and navigate to the folder you saved cloud_sql_proxy.exe then add .\ like so:
.\cloud_sql_proxy.exe -instances="[YOUR_INSTANCE_CONNECTION_NAME]"=tcp:3306
I had the same problem, and i solved it by adding .\ before
so it would be like this
.\cloud_sql_proxy.exe -instances="[YOUR_INSTANCE_CONNECTION_NAME]"=tcp:3306
and I used PowerShell instead of normal cmd
Go to folder where you save proxy exe file and run following command
.\{cloud_sql_proxy file name}.exe -instances={projectID}:{zone}:{sql instance name}:{database}=tcp:{port} -credential_file={service account file path}
For instance related detail go to the instance look for "Instance connection name"
Your command is missing .\ before cloud_sql_proxy.exe -instances="[MyInstanceConnectionName]"=tcp:3306

How can I execute Adobe After Effects via an EC2 Windows Server 2012 Instance?

I have an After Effects script that renders a custom video based on strings passed to it via a webpage form and some python code. It runs just fine when I execute the python code from a remote desktop connection using the administrator account. However when I try to execute it via the web page I can see that After Effects blinks on for a second in the Task Manager but it fails to output any files like it does when run as the administrator.
I'm assuming this is due to some crazy permissions issues with IIS. I've added the after effects executable directory as a virtual directory in IIS. I've also allowed the after effects executable file in the CGI restrictions. I've also set the executables folder to allow read, write, and execute permissions for the IIS-User account.
Any ideas?

Categories