Generating a file path - bash

Does anyone know a tool for showing the path from one file to another? Ie, if my css file is in:
/User/foo/bar/source/assets/myscreen
and my image is in:
/User/foo/bar/gamethings/smallimages
How can I quickly, without having to count the file levels (which is simple, but tedious, and has to be done often), generate the path from the css to the image?

First, get realpath(1) from GNU Coreutils. Then:
$ realpath --relative-to=/User/foo/bar/source/assets/myscreen /User/foo/bar/gamethings/smallimages
../../../gamethings/smallimages

Related

Extracting images from multiple PDF files using hexapdf - hexapdf no such file or directory # rb_sysopen

I'm in my master thesis and I have to extract images from about 500 pdf files, some people recommended hexapdf to me for this. I was able to install Ruby and hexapdf and now I'm kinda stuck getting the images out of the pdf's since I don't have a coding background. Any tips?
Thanks in advance.
I tried using the basic command for only one pdf to see what happened by using 'hexapdf images' followed by the pdf name but the result was 'no such file or directory # rb_sysopen'.
If you're getting no such file or directory # rb_sysopen, then that signals that the file you are trying to open does not exist. It sounds like this is probably the PDF that you are trying to extract images from.
I would check that you are following help provided by hexapdf documentation and that the path to your PDF is correct. If the file with your code and the PDF are in the same directory and you are running your code from that file, then you would do something like:
require 'hexapdf'
doc = HexaPDF::Document.open('my_pdf_document_filename.pdf')
If the file is somewhere else on the machine, it may be easiest to use a full file path instead of a relative file path which will depend on your system and such (e.g. /Users/username/thesis/image_processing/files/my_pdf_document_filename.pdf).

Where is libpcap.dylib?

I able to load libpcap.dylib which is confusing cause I can't figure out the actual file location. Doing find / -name libpcap.A.dylib or libpcap.dylib says no such file.
Also finder search with libpcap just results in libpcap.A.tbd and libpcap.rb.
libpcap.A.tbd shows "Install location /usr/lib/libpcap.A.dylib", but it does not actually exist there.
I wanted to locate the actual dylib file cause I running into issue with being able to import function, So I wanted to check file to make sure I have function names correct.
So I wanted to check file to make sure I have function names correct.
The first thing to check is the pcap man page - from the command line, it'd be
man pcap
It's a bit long, but it should mention all the functions available in libpcap; it may be easier than
nm /usr/lib/libpcap.dylib | egrep ' T '
(and doesn't require you to remember that the leading underscores in the output of that command are NOT part of the name of the function, they're a leftover from ancient UNIX history).
Where is libpcap.dylib?
/usr/lib/libpcap.A.dylib. /usr/lib/libpcap.dylib is a symbolic link to it.

Latex - Bibtex/BibLatex - How can I include a file with space in the path?

I am using Mac and
\usepackage{natbib}
It seems that the space in the path caused problems, i.e. Box Sync.
\bibliography{/Users/c082213/Box Sync/AA_My_Papers/MyStats.bib}
I have tried to put them in double "", and it doesn't work on Mac. Is there anyway that we can fix this?
Many thanks!
one solution is to use a relative path.
If the .bib and the .tex file are in the same folder you can just write:
\bibliography{MyStats}
On the other hand, there are many other possible solutions to handle the problem with with spaces in the path. My suggestion is: avoid it to name folders or files with spaces. It will produce problems for some reasons.
I had the same issue with Box and it's default usage of spaces, so I created a soft link having no spaces:
ln -s "Box Sync" Boxsync
then I can use the bibliography command as usual.

openFile with pandoc 1.13.2 - Windows 8.1

sorry for my english in my post (it is my first on this forum, and my question is perhaps stupid).
I encounter a problem in converting a html file to pdf file with pandoc.
Here is my code in the console
set Path=%Path%;C:\Users\nicolas\AppData\Local\Pandoc
(redirecting to Pandoc directory)
followed by
pandoc --data-dir=C:\Users\nicolas\Desktop essai.html -o essai.pdf
As indicated, my file is in the Desktop, but I got the following error:
pandoc: essai.html: openFile: does not exist (No such file or directory)
I get the same error if i do (with the file essai.html in the same folder as pandoc.exe):
pandoc essai.html -o essai.pdf
Have you any idea of the cause of my problem? (I precise that the file's name i want to convert is correct).
Remark: My original problem was to create a pdf faithful to the beautiful html file generated by Ipython Notebook via pandoc but I encounter the same kind of problem when i want to convert a .ipynb file in pdf with nbconvert.
I finally solve my problem by adding the full paths to my files (But I have used wkhtmltopdf which is simpler to use for a good result.)

Make binary believe it is in another directory

On a Linux system I have a binary (bin.exe) which needs to read an input file (input.cfg), where the names of other data files (data.txt) are specified. Usually both binary, input file and data files were in the same directory. Now and for organization reasons I need binary file to be in $SOMEPATH/bin and input and data files in $SOMEPATH/input.
I do not know how to do this. If I try
$SOMEPATH/bin/bin.exe $SOMEPATH/input/input.cfg
I get
error, "data.txt" not found
One solution would be to include absolute of relative path of "data.txt" in input.cfg, but the binary does not accept this.
I thought about somehow fooling the binary so that it thinks it is in $SOMEPATH/input, so that I just do
$SOMEPATH/bin/bin.exe input.cfg
and it works, but I do not know whether this is possible. any hints?
(cd $SOMEPATH/input && $SOMEPATH/bin/bin.exe input.cfg)
This is assuming that the program is relying on the current working directory to find the files. If the program is trying hard to find them in the same location as the executable, by consulting /proc/<pid>/exe for example, then you may be out of luck.

Resources