how do I run my .py file from within python command line? - windows

background info:
I know this question has been asked countless times, but I'm not understanding the answers.
Today is the first time I've ever done anything with python, so I'm a total noob.
I'm using windows 7.
python 3.3.5 lives here: C:\Python33\python.exe
I have a .py file I want to run saved here: C:\Users\Scydmarc\Documents\cs188\python_basics\myfile.py
If I simply double click on myfile.py, it opens, runs, and closes super fast. By doing a perfectly timed printscreen, I can see that it works. It is my understanding that I need to run the file from within python.exe to get the window to stay open and allow me to mess with variables etc after it runs. So I open python.exe. What exactly do I need to type to run myfile.py? I've found lots of people trying to do this, but I guess I'm not understanding the answers. When I try to follow along, I get tangled up with errors. Do you still need to put python before the file name while in the python.exe window? Do I somehow need to specify a full path to the file? Some are actually running from the windows command prompt and not the python command prompt. When trying to change PYTHONPATH, are you supposed to do that from inside python, or the windows command prompt? Some examples use '/', while some use '\'. So, I think a complete example (what to actually type, in what window, line by line, with real filepaths) would clarify a lot for me and be super helpful. I'm thinking if I can actually see it done once, I can figure out how to make it do what I want in the future. Thanks for any help you can give.

in your python dir type python.exe pathtofile.py or set python.exe to your classpath
edit: https://www.youtube.com/watch?v=IokKz-LZsEo

Related

Utilizing custom environment paths from other programs with batch file proccesing

I have visited StackOverflow thousands of times and it's always incredibly useful. This will be my first question on this site, after spending the entire day attempting to solve a problem.
Long story short, I use a program who's configuration settings allow for custom user programs to be executed with a button click on the main GUI. Alongside this is an input for a cmd line option. You can see the config in this image.
Configuration Settings Window
So I have created a script to execute and have been trying with no success for the entire day. I don't imagine I have to explain what it's like to keep changing small details and even starting over again a dozen times. Basically, when you highlight an order in the program, I want to move any (*.stl) files from the orders folder. The .bat file converted to exe i tried dozens and dozens of similar scripts like the code below. I have a .bat and a .exe that work fine when I am moving a file from my own directories. But now with this very new to me, environment variable. No matter how I format it, it doesn't work. In the beginning it was always exit code 255. But now I get exit codes 0, 1, but no file copy. I have made progress and but decided I need to ask for help.
Thank you in advance.
edit: enter image description here
for /r %ORDER_FOLDER% %f in (*.stl*) do #copy %f C:\Users\Lap2\Desktop\test_dir

How to compile .lua into Windows .exe?

Question related to Windows platform only.
I can't find documentation on how to approach this.
There are dozens of posts about this, yet most provide answers for mac/linux, most windows specific parts lead to dead links or README's that have no useful information.
How do I, for example, make an .exe of the code below? The intent being to share it with another windows user, so that when they click it...it automatically runs the program in command prompt or wherever .exe are supposed to run without them needing to have lua/luac installed on their system.
Or perhaps I'm missing the point here and you need lua/luac installed, otherwise you would need to convert to a program language that's already installed on everyones' windows systems like C...? Regardless I need something that works for the purpose described. Could I make a folder with lua.exe and luac.exe and input.lua and make an .exe that loads command prompt and runs the command to compile input.lua? new_folder: lua.exe, luac.exe, input.lua, run.exe
> --input.lua
print("type ur name")
name=io.read()
print(#name)
print("your name is " name)
I'm not aware of anything in wxlua that can compile a lua file into an executable. There is wxLuaFreeze executable that allows to concatenate a lua script to it to generate a new executable that will run that script when executed. See the documentation for details: http://wxlua.sourceforge.net/docs/wxlua.html#C7.3.

command line expand overwritten

[Not sure if this is the right place for this question, if not, please correct me!]
I am having frequent BSOD issues with my graphics card driver. On closer inspection, it turns out there is an issue with a driver file called atikmpag.sys - an issue that other people have apparently faced many times before. I found a workaround on this website. In short, the thing I need to do is expand the driver file atikmpag.sy_ to atikmpag.sys. This should be done with the following command line (I have put the file atikmpag.sy_ in a folder called C:\test):
cd C:\test
expand atikmpag.sy_ atikmpag.sys
however, when I execute those two lines, I get a LOT of beeping noises accompanied with the following screen:
After some time, the command line will start responding again and I am left with the message 'atikmpag.sys: no such file or directory' (see image below)
Upon running expand /? I found that the /? flag was not recognized by command prompt. I needed to call expand --help, which showed me the following screen:
It seems to me that I probably installed some program that overwrote the standard windows expand command prompt function and replaced it with some tab-removal functionality. Now my question is: how can I restore/access the original windows function? Or alternatively: is there any other way I can extract the original atikmpag.sy_ file to atikmpag.sys?
You're using the wrong expand (the one which expands tabs to spaces, which makes no sense since this is a binary).
You should be using the one from the windows directory, C:\Windows\System32\expand.exe. If you've lost it try sfc /scannow if you haven't already, or if you need it quick grab it from one of the internet's download sites, and hope it's not riddled with malware.

How do I call out to a command-line program from a gnome shell extension?

I have written a simple shell script to accomplish a common task, and I want to be able to run it whenever a button is clicked. I've used gnome-shell-extension-tool to create the Hello World example already, but now I need to know how to simply have it run an arbitrary command when clicked. There is no input or output to be concerned with; it just needs to run.
After some more creative googling, I've found the solution:
const Util = imports.misc.util;
Util.spawn(['/path/to/program', 'arg1', 'arg2'])
const GLib = imports.gi.GLib;
let stuff = GLib.spawn_command_line_sync("cat hello.txt")[1].toString();
For those looking to read the output of the command, use this.
The default working directory for Gnome shell extensions is the user's home directory.
Just thought I'd mention these things, because it took me a while to figure them out.

How do I save my command snippets for quick access from the commandline?

I have a huge file with all the commands I use on and off the commandline. This file is getting harder to open and navigate as its size gets larger. I am looking for a commandline utility that makes this process easier. I found this gem, which does something similar to what I want, but it's terrible with long lines of code with multiple quotation marks.
What does everyone use to keep your code snippets and easily access it from your terminal?
I keep a similar file myself. This example isn't directly useful with your file. However when I find that I need to run a particular command I recently used, without looking it up again, I run a grep on history.
For example:
history | grep "svn co"
You may try Komandi, a multiplatform command snippets manager.

Resources