#10 #13 at the end of console line ! in SH - console

screenshot
Hello People!,
I am trying to start AVRDUDE from a .sh script.
Only the #13 is missing at the end of eatch line.
Does anybody know what command to put in my .sh script, so the lines appear with #10#13 at the end?
PS: It is to execute a FPC console program where AVRDUDE has to run in de commandline parameters, line by line. So maybe a SH script in between. To solve it.
Greets, Wouter van Wegen

Related

What does `python3 ()` do?

While trying to execute a timeit command on the command line using the python command line interface I accidentally put .function() on the outside of the command like so:
$ python3 -m timeit '<code>'.function()
Rather than the timeit command being executed, I was prompted as such:
function>
Thinking I had entered the python repl I tried to quit with q. Yes, I'm aware quit() is the correct way to do this. Having returned to the command line, I noticed the error and corrected it like so:
$ python3 -m timeit `<code>.function()`
I expected this code to execute correctly, but instead I received the following error:
python3:7: command not found: q
After discussing it with some colleagues, it was suggested that I check which python was being used:
$ which python3
python3 () {
q
}
This was not what I was expecting! Normally the result would be /usr/local/bin/python3. Through some trial and error I was able to determine that the minimal case to reproduce this is:
$ python3 ()
function> q
$
Now that the context is out of the way, I have two questions about the behaviour I witnessed:
1. What exactly does python3 () do?
2. How do I return execution to its original state in the same terminal window? I'm aware I can open a new terminal window and the original state exists in that window.
The syntax foo () is used in POSIX-compliant shells (such as bash, dash, and zsh) to define a function. Your entire snippet defines a function called python3 and executes the command q when it's ran. You can bypass shell functions and aliases using the command command: command -p python3 myfile.py
To remove the function from the current shell process, you can use unset -f python3. If it keeps coming back after starting new shells, then it's likely defined in one of you shell initialization files.

understanding TYPE in lsof output

I opened a file through python. So, i did a lsof on the python process. output of lsof has the following line
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
python 15855 inaflash 3w REG 0,25 0 4150810088 /home/inaflash/he.txt
Thing is, it has 3w. which means that the file is open for writing. But, i actually opened the file as follows
a = open('he.txt','r')
I read that, w means file is open for write. Can anyone help me understand why its w instead of r
I tried the same code in Python 3 and my file is opened in read mode.
Are you sure your file is the same opened with python and same python process ?
Maybe you forgot to close the file somewhere in your code after opened it in write mode.
Edit: Also tried in Python 2, same result (read mode)

Pythonwin.exe does not indicate the line of code for runtime errors

This is a tricky problem because it deals with the Pythonwin.exe user interface itself, and not my code.
When I run a file with the following code in it, I would expect that if it errors, it would show the line that it failed on in the traceback output
I literally just create an untainted 32-bit python 3.5 environment, installed pywin32, and opened my testfile.py to run it and here were the results.
Screenshot
If you see the line saying
File "C:\testfile.py", line 2, in <module>
foo = 2 #this line works fine, but is identified as the traceback line
I would have expected this to point to line 5 and not line 2.
Inside a larger script, this is much more problematic as I need to guess which line caused the error based on the context.
To replicate my situation in an anaconda-based environment:
1. open the Anaconda Command Prompt
2. run the following lines to generate our environment
set CONDA_FORCE_32BIT=1
conda create -n test python=3.5
activate test
conda install -y pywin32
Save "testfile.py" file with text:
#comment
foo = 2 #this line works fine, but is identified as the traceback line
a=2
a=3
a=b #this line causes the error, but isn't identified
Open PythonWin.exe, open the "testfile.py" file and hit F5 or click Run
And it is not just an issue in anaconda installed environments.
If anyone has any insight into how to make it report the bad line of code, or why it is acting in this way, please let me know. Thanks!

run rscript from command line until it succeeds

I need to run an R script from command prompt in windows. The problem is that the R script has some lines which sometimes gives warnings/errors (not any logical or syntax error but just fails due to data issue. Anyway, this is not important). So, instead of re-running it manually every time it fails, I want to put the system command in some kind of loop to run it until it succeeds i.e. does not return any warnings/errors.
I am using the following system command to run the r script in question.
Rscript D:/r_code.r 123 544
# 123 and 544 are two numeric arguments which I pass to the r script.
How do I do I achieve my task?
NOTE: In the end, I need to run a batch file which will have multiple commands to run different R scripts and I need to put this loop until it succeeds over every command in it. Batch file will look like:
Rscript D:/r_code1.r 123 544 # put loop condition here
Rscript D:/r_code2.r 125 524 # put loop condition here
Rscript D:/r_code3.r 156 553 # put loop condition here
Rscript D:/r_code4.r 187 587 # put loop condition here
Adding a screenshot showing how error or warning gets displayed in command prompt as soon as I run the rscript command
You could try something like this:
#echo off
:loop
Rscript D:/r_code.r 123 544 | findstr "exception error warning" >nul 2>nul
set warningfound=%errorlevel%
if %warningfound% neq 1 goto loop
This executes a command, and if it finds one of the words in the findstr command in the output it goes to the loop tag, and executes it again.

Running Groovy script from the command line

When I did which groovy, I got the below output:
/usr/local/bin/groovy
So I went ahead and created a helloworld.groovy with the below content
#!/usr/local/bin/groovy
println "hello world"
After that I did chmod +x helloworld.groovy and attempted to run the file with ./hellworld.groovy and sadly, I got this error ./helloworld.groovy: line 2: print: command not found
I could get rid of the error by changing to
#!/usr/bin/env groovy
println "hello world"
Why would the first method cause the error?
You need to run the script like this:
groovy helloworld.groovy
#!groovy
println("hello world!")
$ chmod +x script.groovy
$ ./script.groovy
It will work on Linux kernel 2.6.28 (confirmed on 4.9.x). It won't work on FreeBSD and other Unix flavors.
Your /usr/local/bin/groovy is a shell script wrapping the Java runtime running Groovy.
See the Interpreter Scripts section of EXECVE(2) and EXECVE(2).
#!/bin/sh
sed '1,2d' "$0"|$(which groovy) /dev/stdin; exit;
println("hello");

Resources