Error while viewing a pdf file using latex-suite in macVim - vim

I get this error after typing lv for viewing the pdf file in macVim.
Note: after compiling it (with ll) without any problem:
Error detected while processing function Tex_ViewLaTeX:
line 34:
E121: Undefined variable: s:viewer
E116: Invalid arguments for function strlen(s:viewer)
E15: Invalid expression: strlen(s:viewer)
line 39:
E121: Undefined variable: appOpt
E15: Invalid expression: 'open '.appOpt.s:viewer.' $.'.s:target
line 79:
E121: Undefined variable: execString
E116: Invalid arguments for function substitute(execString, '\V$', mainfname, 'g
')
E15: Invalid expression: substitute(execString, '\V$*', mainfname, 'g')
line 80:
E121: Undefined variable: execString
E116: Invalid arguments for function Tex_Debug
line 82:
E121: Undefined variable: execString
E15: Invalid expression: 'silent! !'.execString
I already defined the pdf viewer in the .vimrc file with
let g:Tex_ViewRule_pdf = 'open -a Preview'
Also tried treating macUnix as Unix with
let g:Tex_TreatMacViewerAsUNIX = 1

Looking at the source code, it seems that the lv function launches the dvi viewer, not the pdf-viewer.
If you want to preview a dvi file, you should have XQuartz installed, and then you can define
let g:Tex_ViewRule_dvi = 'open -a xdvi'
If you want to preview a pdf file with MacVim, you should define a new viewer command altogether, which I don't think can be done without changing the source code.

Related

Why didn't the compiler alert me about the errors by their sequential order? [duplicate]

Python is an interpreted language so it execute the code line by line so when I am running
import csv,re,sys
print len(sys.argv)
if(len(sys.argv)!=2):
sys.exit(0)
filename= #from command line argument
it doesn't execute even a single line and give syntax error.
Now my question is that last line of the code has error but python interpreter execute the code line by line so the code up to the last line is correct so it should execute the code upto the last line but it is giving me the below error and not printing length of sys.argv that I have defined in line 2
File "trace-analysis.py", line 45
filename = # from command line argument
SyntaxError: invalid syntax
I am not getting this behaviour....
please someone explain this ...
python interpreter execute the code line by line
This is false!!!
Python reads the whole file, compiles it to bytecode and then executes the bytecode.
If there is a syntax error anywhere in the file no instruction is run because the interpreter will first try to parse the whole contents of the file and realize it's not a well-formed program.
Python is not bash.
Just ot be clear what I mean with the last statement:
$echo 'print("Hello, World!")
> $(
> ' > test.py
$python test.py # NOTE: no Hello, World in the output
File "test.py", line 2
$(
^
SyntaxError: invalid syntax
$echo 'echo "Hello, World!"
$(
' > test.sh
$bash test.sh # NOTE: there's a Hello, World => bash execute the first statement!
Hello, World!
test.sh: riga 2: EOF non atteso durante la ricerca di ")"
test.sh: riga 4: errore di sintassi: EOF non atteso
My locale is italian. The error is just a standard error message saying that it found an unexpected EOF.
Hence bash does not parse the whole file before starting execution. Quod est demostrandum

gsutil got an syntax error with subprocess.Popen

In my Case, I want to upload all of pdf file to google cloud storage.
So I use google-sdk with pytho subprocess for practice instead of "google.cloud.storage API".
But there is an error below:
Code:
from subprocess import Popen
def subprocess_cmd(command):
print(f'$>: {command}')
process = Popen(command,
stdout=subprocess.PIPE,
executable='/bin/bash',
shell=True)
proc_stdout = process.communicate()[0].strip()
print(proc_stdout.decode("utf-8"))
Exec Function:
command = "gsutil -m cp -r ./source/*(.pdf|.PDF) gs://<bucket_name>"
subprocess_cmd(command)
Error:
/bin/bash: -c: line 0: syntax error near unexpected token `('
/bin/bash: -c: line 0: `gsutil -m cp -r ./source/*(.pdf|.PDF) gs://<bucket_name>'
You should use this line instead:
command = "gsutil -m cp -r ./source/{*.pdf,*.PDF} gs://<bucket_name>"
See the { } (curly brackets) section in this document about bash wildcards. You can also see this document about gsutil wildcards.

Bash script increments variable, but throws error

I'm trying to process some files in increments of 50. It seems to work, but I'm getting an error that the command isn't found.
File sleepTest.sh:
#!/bash/bin
id=100
for i in {1..5}; do
$((id+=50))
sh argTest.sh "$id"
sleep 2
done
File argTest.sh:
#/bash/bin
id=$1
echo "processing $id..."
The output is
sleepTest.sh: line 6: 150: command not found
processing 150
sleepTest.sh: line 6: 200: command not found
processing 200
sleepTest.sh: line 6: 250: command not found
processing 250
sleepTest.sh: line 6: 300: command not found
processing 300
sleepTest.sh: line 6: 350: command not found
processing 350
So it clearly has an issue with how I'm incrementing $id, but it is still doing it. Why? And how can I increment $id. I tried simply $id+=50, but that did not work at all.
Leave out the $.
((id+=50))
((...)) performs arithmetic. $((...)) performs arithmetic and captures the result as a string. That would be fine if you did echo $((...)), but if you write just $((...)) then the shell treats that number as the name of a command to execute.
var=$((21 + 21)) # var=42
echo $((21 + 21)) # echo 42
$((21 + 21)) # execute the command `42`
Such assignments are legal inside arithmetic expressions. However, bash still tries to interpret the result of the expression as the name of a command. Either pass it as an argument to the : command (the POSIX way)
: $((id+=50))
or use a bash arithmetic statement instead of an arithmetic expression
((id+=50))

Bash function call error

I need some help in Bash function while passing arguments. I need to pass arguments into SQL query in Bash but I am getting error message.
#!/bin/bash --
whw='mysql -uroot -proot -habczx.net'
function foo() {
for v in "$#"; do
eval "$v"; # line 9
echo "${v}";
done
${whw} -e"select id, idCfg, idMfg, $DATE from tblMfg"
}
foo DATE="curdate()"
Below is the error message I get:
$ sh test4.sh
test4.sh: eval: line 9: syntax error near unexpected token `('
test4.sh: eval: line 9: `DATE=curdate()'
test4.sh: line 9: warning: syntax errors in . or eval will cause future versions of the shell to abort as Posix requires
DATE=curdate()
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from tblMfg limit 4' at line 1
==
If I change in function call to below I do not get any error message:
foo DATE="2014-12-21"
==
Any help?
Thanks!
The problem is the evaluated expression. You can see that by typing it:
$ DATE=bla()
-bash: syntax error near unexpected token `('
If you put it in quotes, it will work:
$ DATE="bla()"
In order to pass the quotes to the eval, they need to be protected from evaluation at callsite:
foo 'DATE="curdate()"'
should do the trick.
BTW: this is rather dangerous to eval a string, especially if the arguments are from untrusted users, one could use foo "rm -rf /" :)
I am not sure why you need the eval, instead of $DATE you could also use $1 and then
${whw} -e"SELECT ... $1...."
foo "curdate()"

Modifiying j2me midlet

I want to change some strings in opensource app ( testing purpose ). So I decompiled my app using jad decompiler.
Original class file http://dl.dropbox.com/u/32657135/YourTube.class
issued command Jad.exe Yourtube.jar.java
Got jad as output http://dl.dropbox.com/u/32657135/YourTube.jad.java
Compiling Code Again with no modification
command in cmd javac Yourtube.jar.java
Error
YourTube.jad.java:57: error: ';' expected
JVM INSTR monitorenter ;
^
YourTube.jad.java:57: error: not a statement
JVM INSTR monitorenter ;
^
YourTube.jad.java:59: error: not a statement
this;
^
YourTube.jad.java:66: error: ';' expected
JVM INSTR monitorenter ;
^
YourTube.jad.java:66: error: not a statement
JVM INSTR monitorenter ;
^
YourTube.jad.java:68: error: not a statement
this;
^
6 errors
I want to know, why I am getting this error on recompiling. Is there anything wrong I am doing?

Resources