w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Command line download large (500+mb) file using vbscript
Here I see you have uses HTTP which doesnot support ftp. So my suggestion would be to use Wget. http://www.codeproject.com/Tips/506439/Downloading-files-with-VBScript

Categories : Http

Is it possible to use awk to print all line in a file and then do a command on a single column?
It its possible to run a shell command from awk. You just need proper quoting, like this: echo "123" | awk '{ print $0 | "openssl dgst -sha1 | sed '"'s/^.* //'"'" }' output: a8fdc205a9f19cc1c7507a60c4f01b13d11d7fd0

Categories : Bash

Always given command line before python fabric command is executed on remote
Interesting, I don't have such issue, your code works fine for me (up to adding env.key_filename and env.password) c:work>fab hello [x.x.x.x] Executing task 'hello' [x.x.x.x] run: touch hello.world Done. Disconnecting from x.x.x.x... done. I'm using Fabric 1.7.0 and Paramiko 1.11.0. Possibly it's a problem of the terminal on your server.

Categories : Python

Defining the command line arguments of a linux command in python
format is your friend: import os, sys if len(sys.argv) == 2: os.system("sudo rtcwake -m off -s {}".format(sys.argv[1])) else: print "usage: ..." so the seconds are command line parameters. Or, you can make it interactive: import os secs = raw_input() os.system("sudo rtcwake off -s {}".format(secs)) to verify that the user input is an integer: try: secs = int(secs) except: print 'usage: '

Categories : Python

getting a file to print to a specific printer using notepad and command line in visual basic
Some applications (including Notepad) support a printto command. Notepad's is /pt printername. You'll probably have to experiment some to get the printer name just right - I believe it's the name of the printer as seen in Control Panel, but it may be the name of the device or driver itself. (A few quick tests should help you figure out which applies.) Shell("NOTEPAD /PT MyLaserJet C:Temp est.txt") Of course, the proper solution to this problem is to change your application so it doesn't use Shell("notepad",...) to do the printing, but actually sends the text to the printer itself. You can then have the user set up the printer once, save that configuration, and then automatically send the text to the proper printer every time. Using an external application to do the work your app should

Categories : Shell

New to python - Why does only the first line print?
While Python may look like English, it isn't English. What you wrote will it be interpreted like: if (read == 'Yes') or ('yes') 'yes' is truthy, so your if statement really acts like: if (read == 'Yes') or True False or True and True or True are both True, so your first if statement will always be true. Be explicit: if read == 'Yes' or read == 'yes' Or just do it the simpler way: if read.lower() == 'yes'

Categories : Python

Python doc strings print instead of a new line (Python 2.7.5 on a Mac)
That is because the list.__doc__ is a string. When you just type list.__doc__ you will get the contents like this : >>> list.__doc__ "list() -> new empty list list(iterable) -> new list initialized from iterable's items" However if you type print list.__doc__ >>> print list.__doc__ list() -> new empty list list(iterable) -> new list initialized from iterable's items So the print function properly formats the string to include the linebreak. Hope that helps :)

Categories : Python

Python Sqlite, not able to print first line
ID and sno are not data, they are part of your table structure (the column names). If you want to get the names of the columns you need to do something like connection = sqllite3.connect('test.sqlite') cursor = connection.execute('select * from abc') names = list(map(lambda x: x[0], cursor.description))

Categories : Python

New line in python print() function
First of all print isn't a function in Python 2, it is a statement. To suppress the automatic newline add a trailing ,(comma). Now a space will be used instead of a newline. Demo: print 1, print 2 output: 1 2 Or use Python 3's print() function: from __future__ import print_function print(1, end=' ') # default value of `end` is ' ' print(2) As you can clearly see print() function is much more powerful as we can specify any string to be used as end rather a fixed space.

Categories : Python

print a character at end of line-Python
Your lines, when split, couldn't possibly have an index going up to 9 (well they don't for me). But anyways, it looks like your lines are separated by a new line (' ') and so when you're accessing the last element in the list, you're also accessing the new line. You can do: agent = '"'+(line.split(' ')[9]).rstrip(' ')+'"' Also, your last line doesn't need all that concatenation. You can simplify it to: fo.write(ip + ' - - ' + time + ' ' + method + ' ' + status + ' 0 ' + referrer + ' ' + agent) Or even: fo.write("{0} - - {1} {2} {3} {4} 0 {5} {6}".format(ip, time, method, status, referrer, agent)

Categories : Python

.txt file does not print after being written with a join lines command in python
It looks like you haven't closed the file handle, and the write may not have finished. close function needs to be called :: textA.close(). To not have to worry about remembering to close files, use the with statement. with open('textA.txt', 'w') as f: f.write(' '.join(lines[1:72])) And then, read back your file, as required with open('textA.txt') as f: print f.readlines()

Categories : Python

How can I print variable and string on same line in Python?
Use , to separate strings and variables while printing: print "If there was a birth every 7 seconds, there would be: ",births,"births" , in print statement separtes the items by a single space: >>> print "foo","bar","spam" foo bar spam or better use string formatting: print "If there was a birth every 7 seconds, there would be: {} births".format(births) String formatting is much more powerful and allows you to do some other things as well, like : padding, fill, alignment,width, set precision etc >>> print "{:d} {:03d} {:>20f}".format(1,2,1.1) 1 002 1.100000 ^^^ 0's padded to 2 Demo: >>> births = 4 >>> print "If there was a birth every 7 seconds, there would be: ",births,"births" If there was a birth every 7 seconds, there

Categories : Python

How can I print a long line in realtime in python?
You can remove this line, it's not needed: line = line.replace(' ', '').replace(' ', '') And if you want to print word by word do this: for line in iter(p.stdout.readline, ''): for word in line.split(): print(word) sys.stdout.flush()

Categories : Python

Print multiple variables in one line using python
There are a number of ways that you could go about this. The simplest is probably to initialize an empty string before the if statements. Then, instead of printing split[1] and ip[2], concatenate them to the empty string and print that afterwards. So it would look something like this: printstr = "" if re.search... ... printstr += "Label for first item " + split[1] + ", " if re.search... ... printstr += "Label for second item " + ip[2] print printstr

Categories : Python

azure command line tool for linux machine to upload/download data to/from Azure Storage
there's support for upload and download : azure storage blob upload [options] [file] [container] [blob] azure storage blob download [options] [container] [blob] [destination] if not seeing them try to update your cli tools first: npm install azure-cli -g hope this helps

Categories : Linux

Python: Print to one line with time delay between prints
In Python2, if you put a comma after the string, print does not add a new line. However, the output may be buffered, so to see the character printed slowly, you may also need to flush stdout: from time import sleep import sys print 'L', sys.stdout.flush() sleep(0.1) So to print some text slowly, you could use a for-loop like this: from time import sleep import sys def print_slowly(text): for c in text: print c, sys.stdout.flush() sleep(0.5) print_slowly('LOA') In Python3, change print c, to print(c, end='')

Categories : Python

Python script to unzip and print one line of a file
I am assuming that: You meant to have quotes around the file name in your script. You actually want the third line (as your post suggests) and not the third character (as your script suggests) In this case the following should work: import gzip data = gzip.open('pagecounts-20130601-000000.gz', 'r') data.readline() data.readline() print data.readline()

Categories : Python

How to print string inside a parentheses in a line in Python?
You can use regex: >>> import re >>> s = "562: DEBUG, CIC, Parameter(Auto_Gain_ROI_Size) = 4" >>> t = "711: DEBUG, VSrc, Parameter(Auto_Contrast) = 0 " >>> myreg = re.compile(r'Parameter((.*?))') >>> print myreg.search(s).group(1) Auto_Gain_ROI_Size >>> print myreg.search(t).group(1) Auto_Contrast Or, without regex (albeit a bit more messier): >>> print s.split('Parameter(')[1].split(')')[0] Auto_Gain_ROI_Size >>> print t.split('Parameter(')[1].split(')')[0] Auto_Contrast

Categories : Python

How to switch between python 2.7 to python 3 from command line?
For Windows 7, I just rename the python.exe from the Python 3 folder to python3.exe and add the path into the environment variables. Using that, I can execute python test_script.py and the script runs with Python 2.7 and when I do python3 test_script.py, it runs the script in Python 3. To add Python 3 to the environment variables, follow these steps - Right Click on My Computer and go to Properties. Go to Advanced System Settings. Click on Environment Variables and edit PATH and add the path to your Python 3 installation directory. For example,

Categories : Python

How can I print a string using a while loop with an interval in between letters (on the same line) in Python 3.2?
try flushing it for l in activ: print(l, end=" ") sys.__stdout__.flush() sleep(0.1) no idea if it will work since I am assuming you are using py3x and it works fine in my system with or without the flush flush just forces the output buffer to write to the screen ... normally it will wait until it has some free time to dump it to the screen. but sleep was locking it. so by flushing it you are forcing the content to the screen now instead of letting the internal scheduler do it ... at least thats how I understand it. Im probably missing some nuance

Categories : Python

Getting Command line in Python
Just use sys.argv, like this: import sys # this part executes when the script is run from the command line if __name__ == '__main__': if len(sys.argv) != 2: # check for the correct number of arguments print 'usage: python kb.py cur' else: call_your_code(sys.argv[1]) # first command line argument Note: sys.argv[0] is the script's name, and sys.argv[1] is the first command line argument. And so on, if there were more arguments.

Categories : Python

How to search for word in text file and print part of line with Python?
Here's one way - split each line by spaces, then search each part for "color=": with open("textfile.txt") as openfile: for line in openfile: for part in line.split(): if "color=" in part: print part

Categories : Python

Python - Need to get argument on command line
argparse is beautiful. Redesign your command line interface for it or write your own CLI-parser. CLI example: args = ['firstargument', 'secondargument', '-s', 'thirdargument', '-s', 'fourth', 'fifth', '-s', 'sixth'] last_arg = None container = [] marker = '-s' for arg in args: if (arg != marker): last_arg = arg else: container.append(last_arg) print container Result of execute: $python test.py ['secondargument', 'thirdargument', 'fifth']

Categories : Python

Python, Command Line, Windows
After modifying your path, did you start up a new instance of the command prompt (this has caused me much grief in the past)? To check if your path change was successful: echo %PATH% and check to see if C:Python2.7.5 was appended to it. If not then run: set PATH=%PATH%;C:Python2.7.5 To call a python script with a command line argument (assuming that your script is in the current working directory): python letter_counts.py "Your Text Goes Here" OR if you just want to be overly verbose (or your PATH still isn't right): C:Python2.7.5python.exe .letter_counts.py "Your text still goes here" EDIT: Make sure you are doing this from the command prompt and not the python interpreter. To access the command prompt you can hit: 1. Windows Key + R 2. type "cmd" (without quotes) and hit

Categories : Python

Run sqlite3 with python in command line
Python itself dosen't contain a sqlite3 command. But the SQLite library includes a simple command-line utility named sqlite3 (or sqlite3.exe on windows) that allows the user to manually enter and execute SQL commands against an SQLite database. You can download it from here.

Categories : Python

Flyway command line filesystem migrations from actual command line input
flyway.cmd -configFile=/path/to/other/configFile.conf should do what you want. I just checked and it seems I forgot to document this on the website (It is in the usage description of the tool itself). Could you file an issue against the website, requesting this to be added?

Categories : Windows

Basics of Command Line Arguments, Python
You want to use the sys.argv list from the sys module. It lets you access arguments passed in the command line. For example, if your command line input was python myfile.py a b c, sys.argv[0] is myfile.py, sys.argv[1] is a, sys.argv[2] is b, and sys.argv[3] is c. A running example (testcode.py): if __name__ == "__main__": import sys print sys.argv Then, running (in the command line): D:some_path>python testcode.py a b c ['testcode.py', 'a', 'b', 'c']

Categories : Python

Complete as-you-type on command line with python
I would try with "curses" library: http://docs.python.org/2/library/curses.html You have a related topic at: How to make python autocompletion display matches?

Categories : Python

How To Run A Python File From Windows Command Line
If you want to know How do I run a .py file from the Python interpreter? this will work import sys sys.path.append("C:\Users\Myname\Desktop\Python") import Python-Test But your question says from the command line, which has been answered in the comments.

Categories : Python

How to open a window from the command line within a Python script?
You can use subprocess module. subprocess is a newer way to spawn processes rather than using os.spawn*() or os.system(). In your case: import subprocess subprocess.Popen(["ds9"]) This should run ds9 in background. See the documentation here.

Categories : Python

Python: Multi-threaded Command Line Animation
I think curses would do the job. Have a look at what is possible in this example

Categories : Python

Command line arguments as variable definition in Python
This is a relatively simple task with ast.literal_eval and string splitting -- But only if you have a really well defined syntax. (e.g. only 1 of --foo=bar or --foo bar is allowed). import argparse import ast parser = argparse.ArgumentParser() #allow the creation of known arguments ... namespace,unparsed = parser.parse_known_args() def parse_arg(arg): k,v = arg.split('=',1) try: v = ast.literal_eval(v) #evaluate the string as if it was a python literal except ValueError: #if we fail, then we keep it as a string pass return k.lstrip('-'),v d = dict(parse_arg(arg) for arg in unparsed) print(d) I've put the key-value pairs in a dictionary. If you really want them as global variables, you could do globals().update(d) -- But I would seriously a

Categories : Python

Python arguments cuts at < when reading from command line
you need to escape the < sign. try calling: python time.py python ratatosk.py < input.txt it might be better to use a different character than < so that running this command is easier

Categories : Python

Hadoop mapreduce python command line arguments
You can read the input file from os.environ. For example, import os input_file = os.environ['map_input_file'] Actually, you can also read other JobConf from os.environ. Note: During the execution of a streaming job, the names of the "mapred" parameters are transformed. The dots ( . ) become underscores ( _ ). For example, mapred.job.id becomes mapred_job_id and mapred.jar becomes mapred_jar. To get the values in a streaming job's mapper/reducer use the parameter names with the underscores. See Configured Parameters. I also find a very useful post for you: A Guide to Python Frameworks for Hadoop.

Categories : Python

Execute process from the windows command line in Python
By trying your code it prints out PreprocessedTufts8199PLAIN.txt.xml file name. I'm not sure if the .txt.xml extension was the desired result. If your file has only .xml extension, then you're not stripping away the original .txt header. Try to change this line: outFile = file(inFile[(str(inFile).rfind('\'))+1:] + '.xml') Into this code: fnameext = inFile[(str(inFile).rfind('\'))+1:] fname,fext = os.path.splitext(fnameext) xmlfname = fname + '.xml' xmlfpath = os.path.join(".", xmlfname) print "xmlfname:", xmlfname, " xmlfpath:", xmlfpath print "current working directory:", os.getcwd() outFile = open(xmlfpath, "r") Answer for extension stripping.

Categories : Python

How to run python program on command line with different input possibilities
You'll have to make all arguments optional and validate them yourself: ap=argparse.ArgumentParser() ap.add_argument('-c', required=False) ap.add_argument('a', nargs='?') ap.add_argument('b', nargs='?') args = ap.parse_args() if (args.c is not None): # process c elif (args.a is not None and args.b is not None): # process a and b else: # validation errors If you were willing to make a and b a single named parameter instead of positionals, you could use mutual exclusion to do this for you. Mutually exclusive groups require all parameters in them to be optional, and named parameters can only be required. ap=argparse.ArgumentParser() g = ap.add_mutually_exclusive_group(required=True) g.add_argument('-ab', nargs=2, required=False) g.add_argument('-c', required=False) args =

Categories : Python

How do I run Python script using arguments in windows command line
To execute your program from the command line, you have to call the python interpreter, like this : C:Python27>python hello.py 1 1 If you code resides in another directory, you will have to set the python binary path in your PATH environment variable, to be able to run it, too. You can find detailed instructions here.

Categories : Python

How can I use python command line arguments that change at run time?
The whole configuration is done at runtime. The examples use string constants for the names, but you are not bound to that. You first load the configuration, then when you have all the elements, simply loop over those and register them as arguments: parser = argparse.ArgumentParser(....) for element in configuration_elements: parser.add_argument('--' + element, type=float, ...) then parse your command line. Alternatively, argparse.ArgumentParser() as a partial parsing mode as well; simply call parser.parse_known_args() to parse everything that argparse does know about, it'll return a namespace object (all the options it could parse) and the remaining arguments it didn't know how to handle: >>> parser = argparse.ArgumentParser() >>> parser.add_argument('--foo')

Categories : Python

How can I read the Command Line feedback from Python os.system()?
With your eyes. os.system only returns a number back to your process. You should use the subprocess module to read the stdout back into your process eg subprocess.check_output result = subprocess.check_output(['snmpget', '-v', '3', '-u', 'initial', '172.17.171.113', '1.3.6.1.2.1.1.5.0'])

Categories : Python

Why does python's recursive copy not work the same as on the command line?
Seems os.system changes the shell it executes in to sh: mike@mike-VirtualBox:~/head$ echo $0 bash mike@mike-VirtualBox:~/head$ python Python 2.7.3 (default, Apr 10 2013, 06:20:15) >>> import os >>> os.system("echo $0") sh When the copy command is executed via Popen with a bash shell, it works as expected: >>> import subprocess >>> sp.Popen("cp -rf ./applications/icom_app_template ./applications/my_dir", shell=True, executable="/bin/bash") >>> exit() mike@mike-VirtualBox:~/head$ tree ./applications/my_dir/ ./applications/my_dir/ ├── cdl │ ├── include │ ├── Makefile │ ... │ └── other ├── cds │ ├── include ... The only oddity that I do not have an answer for is that if I

Categories : Python



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.