This shows the last saved screenshot (on my Desktop path):
ls -t | head -n1
This prints perfectly:
lp -o -scaling=50 -o media=Custom.60x42mm -o page-left=0 -o page-right=0 -o page-top=5 -o page-bottom=5 image.png
How does one combine them?
Without really knowing what I'm doing I've tried this:
ls -t | head -n1 |awk '{lp -o -scaling=50 -o media=Custom.60x42mm -o page-left=0 -o page-right=0 -o page-top=5 -o page-bottom=5 $0}'
which, naturally fails:
lp -o -scaling=50 -o media=Custom.60x42mm -o page-left=0 -o page-right=0 -o page-top=5 -o page-bottom=5 "$(ls -t | head -n1)"
Or more clear:
filetouse="$(ls -t | head -n1)"
lpoptions=( -o -scaling=50 -o media=Custom.60x42mm -o page-left=0 -o page-right=0 -o page-top=5 -o page-bottom=5 )
lp "${lpoptions[#]}" "${filetouse}"
Ok, just managed to do it.
This worked:
ls -t | head -n1 | xargs -I {} lp -o -scaling=50 -o media=Custom.60x42mm -o page-left=0 -o page-right=0 -o page-top=5 -o page-bottom=5 {}
Thanks to this question.
Related
I am trying to use the makefile for my work related to SPheno. I am on macOS. When I try to use the command "make Model=Scotogenic". it's showing "*** missing separator". I went through lot of forums and added tabs. when I tried to do it again , now it's showing "*** commands commence before first target" . I am using the default textedit in macOS. I am attaching both the code and screenshot. The terminal screenshot
Code:
# PreDef = -DGENERATIONMIXING -DONLYDOUBLE -DSEESAWIII
PreDef = -DGENERATIONMIXING -DONLYDOUBLE
# setting various paths
InDir = ../include
Mdir = ${InDir}
name = ../lib/libSPheno.a
#
# options for various compilers
#
# Intels ifort, default in optimized mode
F90 = ifort
comp = -c -O -module ${Mdir} -I${InDir}
LFlagsB = -O
# Intels ifort, debug modus
ifeq (${F90},ifortg)
F90 = ifort
comp = -c -g -module ${Mdir} -I${InDir}
LFlagsB = -g
endif
gfortran
ifeq (${F90},gfortran)
comp = -c -O -J${Mdir} -I${InDir}
LFlagsB = -O
endif
# g95
ifeq (${F90},g95)
comp = -c -O -fmod=${Mdir} -I${InDir}
LFlagsB = -O
endif
# Lahey F95 compiler
ifeq (${F90},lf95)
comp = -c -O -M ${Mdir} -I${InDir}
LFlagsB = -O
endif
# NAG f95/2003
ifeq (${F90},nagfor)
comp = -c -O -DONLYDOUBLE -mdir ${Mdir} -I${InDir}
LFlagsB = -O
endif
.SUFFIXES : .o .ps .f90 .F90 .a
bin/SPheno: ${name} SPheno4.o
${F90} -o SPheno ${LFlagsB} SPheno4.o ../lib/${name}
mv SPheno ../bin
${name}: ${name}(Control.o) ${name}(Mathematics.o) ${name}(RGEs.o) \
${name}(MathematicsQP.o) ${name}(LoopFunctions.o) ${name}(StandardModel.o) \
${name}(Model_Data.o) ${name}(Couplings.o) ${name}(SusyMasses.o) \
${name}(LoopCouplings.o) ${name}(DecayFunctions.o) \
${name}(SusyDecays.o) ${name}(ThreeBodyPhaseSpace.o) \
${name}(ThreeBodyPhaseSpaceS.o) ${name}(Chargino3.o) \
${name}(Gluino3.o) ${name}(Neutralino3.o) \
${name}(Stop3BodyDecays.o) ${name}(Slepton3Body.o) ${name}(BranchingRatios.o) \
${name}(EplusEminusProduction.o) ${name}(TwoLoopHiggsMass.o) \
${name}(LoopMasses.o) ${name}(SugraRuns.o) ${name}(Experiment.o) \
${name}(LowEnergy.o) ${name}(NMSSM_tools.o) ${name}(RPtools.o) \
${name}(LHC_observables.o) ${name}(InputOutput.o)
clean:
rm -f *.o *~ */*.o */*~
cleanall:
rm -f bin/SPheno4 lib/*.a *~ */*.o */*~ include/*
#
# Suffix rules
#
.f90.a:
${F90} ${comp} $<
ar -ruc $# $*.o
rm -f $*.o
.F90.a:
${F90} ${comp} ${PreDef} $<
ar -ruc $# $*.o
rm -f $*.o
.f90.o:
${F90} ${comp} $<
.f90.ps:
a2ps -o $*.ps $<
.h.ps:
a2ps -o $*.ps $<
I have the following makefile. When I run "make" or "make all", I get the following output:
make all -n
protoc -I protos/ --cpp_out=protos-gen/ protos//fd.proto
g++-4.9 -O4 -std=c++14 -g -I/usr/local/include -pthread -c -o protos-gen//fd.pb.o protos-gen//fd.pb.cc
protoc -I protos/ --grpc_out=protos-gen/ --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` protos//fd.proto
python -m grpc_tools.protoc -I protos/ --python_out=protos-gen/ --grpc_python_out=protos-gen/ protos//fd.proto
g++-4.9 -O4 -std=c++14 -g -I/usr/local/include -pthread -c -o protos-gen//fd.grpc.pb.o protos-gen//fd.grpc.pb.cc
Issue is: I don't see the following line executed:
$(CXX) $(CXXFLAGS) $(INCLUDE) $(SOURCE_DIR)/fd_server_grpc.cpp $(DLIB_DIR)/dlib/all/source.cpp -DDLIB_JPEG_SUPPORT=1 -DDLIB_PNG_SUPPORT=1 $(LIB) -lzmq -o $(BIN_DIR)/fd_server_grpc
What am I missing?
======================
SOURCE_DIR = src
BUILD_DIR = build
BIN_DIR = bin
DLIB_DIR = ../../3rdparty/dlib/
all: $(BIN_DIR)/fd_server_grpc $(BIN_DIR)/fd_client_grpc
$(BIN_DIR)/fd_server_grpc: $(PROTOS_GEN_PATH)/fd.pb.o
$(PROTOS_GEN_PATH)/fd.grpc.pb.o $(SOURCE_DIR)/fd_server_grpc.cpp
$(DLIB_DIR)/dlib/all/source.cpp
$(CXX) $(CXXFLAGS) $(INCLUDE) $(SOURCE_DIR)/fd_server_grpc.cpp
$(DLIB_DIR)/dlib/all/source.cpp -DDLIB_JPEG_SUPPORT=1 -DDLIB_PNG_SUPPORT=1 $(LIB) -lzmq -o $(BIN_DIR)/fd_server_grpc
$(BIN_DIR)/fd_client_grpc: $(PROTOS_GEN_PATH)/fd.pb.o
$(PROTOS_GEN_PATH)/fd.grpc.pb.o $(SOURCE_DIR)/fd_client_grpc.cpp
$(DLIB_DIR)/dlib/all/source.cpp
$(CXX) $(CXXFLAGS) $(INCLUDE) $(SOURCE_DIR)/fd_client_grpc.cpp
$(DLIB_DIR)/dlib/all/source.cpp -DDLIB_JPEG_SUPPORT=1 -DDLIB_PNG_SUPPORT=1
$(LIB) -lzmq -o $(BIN_DIR)/fd_client_grpc
.PRECIOUS $(PROTOS_GEN_PATH)/fd.grpc.pb.cc $(PROTOS_GEN_PATH)/fd.pb.cc:
$(PROTOS_GEN_PATH)/fd.pb.o:$(PROTOS_GEN_PATH)/fd.pb.cc
$(PROTOS_GEN_PATH)/fd.pb.cc: $(PROTOS_PATH)/fd.proto
$(PROTOC) -I $(PROTOS_PATH) --cpp_out=$(PROTOS_GEN_PATH) $(PROTOS_PATH)/fd.proto
$(PROTOS_GEN_PATH)/fd.grpc.pb.o:$(PROTOS_GEN_PATH)/fd.grpc.pb.cc
$(PROTOS_GEN_PATH)/fd.grpc.pb.cc: $(PROTOS_PATH)/fd.proto
$(PROTOC) -I $(PROTOS_PATH) --grpc_out=$(PROTOS_GEN_PATH) --plugin=protoc-gen-grpc=$(GRPC_CPP_PLUGIN_PATH) $(PROTOS_PATH)/fd.proto
python -m grpc_tools.protoc -I $(PROTOS_PATH) --python_out=$(PROTOS_GEN_PATH) --grpc_python_out=$(PROTOS_GEN_PATH) $(PROTOS_PATH)/fd.proto
clean:
rm -f $(BUILD_DIR)/* $(BIN_DIR)/* $(PROTOS_GEN_PATH)/*
I figured this out. The line $(CXX) did not start with a tab; had 8 spaces instead. Once I introduced tabs, it worked just fine. Thanks all!
Currently, I am working on a makefile that takes a parameter "CLASS=xxx" and then compiles and does stuff with that value.
In the end, it runs an application ($APP) on a bunch of files.
I enter this command:
make default CLASS=Test_UART
and the makefile processes it thusly:
pc: $(APP)
make -C BUILDENV CLASS=$(CLASS) BUILD=just_filelist OUTPUT=filelist.txt SKIPSELF=yes
../classCvt/classCvt <./Applications/$(CLASS).class> ./Applications/$(CLASS).ujc
time -p ./$(APP) ./Applications/$(CLASS).ujc `cat filelist.txt`
Hence it calls a makefile in my BUILDENV folder which does the following:
#USAGE: make -C <PATH_TO_THIS_FILES_PARENT_DIR> CLASS=<MY_JAVA_FILE_NAME_WITHOUT_JAVA_EXTENSION> OUT=<OUTPUT_FILE_NAME>
SELF := $(dir $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
CLASS ?= PLEASE_SPECIFY_CLASS_PARAM
DIR := $(PWD)#print working directory
CCVT ?= $(SELF)/../../classCvt/classCvt
TOBIN ?= $(SELF)/../../classCvt/tobin
OUTPUT ?=
### Comment: Defining CMD.
ifeq ($(BUILD), just_filelist)
CMD = echo
else
ifeq ($(BUILD), PC)
CMD = echo
else
ifeq ($(BUILD), unopt)
CMD = $(TOBIN)
else
### Comment: Optimized CMD = tobin -c ccvt
CMD = $(TOBIN) -c $(CCVT)
endif
endif
endif
ifeq ($(OUTPUT), )
OUT = &1
else
OUT = $(DIR)/$(OUTPUT)
endif
ifeq ($(SKIPSELF), yes)
MYCLASS =
else
MYCLASS = $(DIR)/Applications/$(CLASS).class
endif
all:
CLASSPATH=$(SELF)/RT/real:$(SELF)/RT/fake:$(DIR) javac $(DIR)/Applications/$(CLASS).java
find $(SELF)/RT/real -iname "*.class" -type f > $(SELF)/files
ls $(DIR)/Applications/*.class | grep -v "$(CLASS)\.class" >> $(SELF)/files || true
cat $(SELF)/files | xargs $(CMD) $(MYCLASS) >$(OUT)
rm -f $(SELF)/files
What I would like to do is give a command like:
make default CLASS=Test1,Test2,Test3
and the makefile to process it for the 3 classes and put the given classes in a .txt and the default classes in a different .txt, something like this like this:
pc: $(APP)
make -C BUILDENV default_classes BUILD=list_default_classes OUTPUT=list_default_classes.txt
# make -C BUILDENV given_classes BUILD=list_given_classes OUTPUT=list_given_classes.txt CLASS=$(CLASS) SKIPSELF=yes
../classCvt/classCvt `cat list_given_classes.txt`./Applications/$(CLASS).ujc
#here the list_given_classes should now contain the .ujc files
time -p ./$(APP) `cat list_given_classes.txt` `cat list_default_classes.txt`
and for the makefile in the BUILDENV, I expect something like:
default_classes:
CLASSPATH=$(SELF)/RT/real:$(SELF)/RT/fake:$(DIR)
find $(SELF)/RT/real -iname "*.class" -type f > $(SELF)/files
ls $(DIR)/Applications/*.class | grep -v "$(CLASS1)\.class" "$(CLASS2)\.class">> $(SELF)/files || true
cat $(SELF)/files | xargs $(CMD) >$(OUT)
rm -f $(SELF)/files
given_classes:
javac $(DIR)/Applications/$(CLASS).java
find $(SELF)/RT/real -iname "*.class" -type f > $(SELF)/files
ls $(DIR)/Applications/*.class | grep -v "$(CLASS)\.class" >> $(SELF)/files || true
cat $(SELF)/files | xargs $(CMD) $(MYCLASS) >$(OUT)
rm -f $(SELF)/files
However, I'm not sure how to do this for a CLASS parameter containing multiple classes.
I'm thinking to try and parse the Test1,Test2,Test3 value into a list of 1,2,3 and then iterating over it. But no clue if this is a good way and even on how to do it.
What do you guys suggest?
Pretty way:
pc: $(APP)
define BUILD_CLASS
pc: pc-$(CLASS_SPLIT)
pc-$(CLASS_SPLIT):
make -C BUILDENV CLASS=$(CLASS_SPLIT) BUILD=just_filelist OUTPUT=filelist.txt SKIPSELF=yes
../classCvt/classCvt <./Applications/$(CLASS_SPLIT).class> ./Applications/$(CLASS_SPLIT).ujc
time -p ./$(APP) ./Applications/$(CLASS_SPLIT).ujc `cat filelist.txt`
endef
CLASSES := $(shell echo $(CLASS) | tr ',' ' ')
$(foreach CLASS_SPLIT, $(CLASSES), $(eval $(BUILD_CLASS)))
Simple way:
pc: $(APP)
$(foreach C, $(shell echo $(CLASS) | tr ',' ' '), \
make -C BUILDENV CLASS=$(C) BUILD=just_filelist OUTPUT=filelist.txt SKIPSELF=yes && \
../classCvt/classCvt <./Applications/$(C).class> ./Applications/$(C).ujc && \
time -p ./$(APP) ./Applications/$(C).ujc `cat filelist.txt` &&) true
When running make I have the following compilation error:
/bin/sh: 1: /installed/CoinAll/include/coin: Permission denied
This is the Makefile:
#
P=farmer
#
EXE=$(P)
OBJS=main-farmer.o model-farmer.o param-farmer.o pm.h
ADDLIBS=-D.
ADDINCFLAGS=-I.
SRCDIR=~/coin-projects
##########
CXX=g++
CXXFLAGS=-O3 -fomit-frame-pointer -pipe -DNDEBUG -pedantic-errors -Wimplicit -Wparentheses -Wreturn-type -Wcast-qual -Wall -Wpointer-arith -Wwrite-strings -Wconversion
CXXLINKFLAGS=-Wl,--rpath -Wl,/installed/CoinAll/lib
CC=gcc
CFLAGS=-03 -fomit-frame-pointer -pipe -DNDEBUG -pedantic-errors -Wimplicit -Wparentheses -Wsequence-point -Wreturn-type -Wcast-qual -Wall
COININCDIR=/installed/CoinAll/include/coin
# COIN-OR libs
COINLIBDIR=/installed/CoinAll/lib
# Clp
LIBS=-L$(COINLIBDIR) -lCbc -lCgl -lOsiClp -lOsi -lClp -lCoinUtils -lm \
`cat $(COINLIBDIR)/cgl_addlibs.txt` \
`cat $(COINLIBDIR)/clp_addlibs.txt` \
`cat $(COINLIBDIR)/coinutils_addlibs.txt`
INCL=-I`$(CYGPATH_W)$(COININCDIR)`$(ADDINCFLAGS)
CYGPATH_W=
CLEANFILES=\
addBits.o addBits \
addColumns.o addColumns \
addRows.o addRows \
decompose.o decompose \
defaults.o defaults \
driver2.o driver2 \
driver.o driver \
driverC.o driverC \
dualCuts.o dualCuts \
ekk.o ekk \
ekk_interface.o ekk_interface \
hello.o hello \
makeDual.o makeDual \
minimum.o minimum \
network.o network \
piece.o piece \
rowColumn.o rowColumn \
sprint2.o sprint2 \
sprint.o sprint \
testBarrier.o testBarrier \
testBasis.o testBasis \
testGub2.o testGub2 \
testGub.o testGub \
testQP.o testQP \
useVolume.o useVolume
# Part 3
#
all: $(EXE)
.SUFFIXES: .cpp .c .o .obj
$(EXE):$(OBJS)
bla=;
for file in $(OBJS); do bla="$$bla `$(CYGPATH_W) $$file`"; done; \
$(CXX) $(CXXLINKFLAGS) $(CXXFLAGS) -o $# $$bla $(ADDLIBS) $(LIBS)
####
########
############
########
####
clean:
rm -rf $(CLEANFILES)
.cpp.o:
$(CXX) $(CXXFLAGS) $(INCL) -c -o $# `test -f '$<' || echo '$(SRCDIR)/'`$<
.cpp.obj:
$(CXX) $(CXXFLAGS) $(INCL) -c -o $# `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(SRCDIR)/$<'; fi`
.c.o:
$(CC) $(CFLAGS) $(INCL) -c -o $# `test -f '$<' || echo '$(SRCDIR)/'`$<
.c.obj:
$(CC) $(CFLAGS) $(INCL) -c -o $# `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(SRCDIR)/$<'; fi`
I have set the permissions as rwx for /installed/CoinAll/include/coin and for all of its files.
Thanks.
It seems to me as if the Makefile is trying to execute the program /installed/CoinAll/include/coin which instead is a directory. It does not matter how you chmod a directory, it will still not be possible to execute as a program.
The following line:
INCL=-I$(CYGPATH_W)$(COININCDIR)$(ADDINCFLAGS)
in combination with lines like this:
$(CXX) $(CXXFLAGS) $(INCL) -c -o $# `test -f '$<' || echo '$(SRCDIR)/'`$<
... will evaluate to commands like:
g++ (a lot of c++-flags) -I`installed/CoinAll/include/coin` -c -o...
as both $(CYGPATH_W) and $(ADDINCFLAGS) are empty.
When the shell executes a command containing backticks "`"it will replace the text between the backticks with the output from the command between the backticks. Try this:
echo `ls /`
I had this error and it was my anti-virus. Turned on, I get the same error you do. Off, it works just fine. Then turning the anti-virus back on, same error as you get. It was my anti-virus so try turning all it's features off temporarily.
There exist this list:
blablabla
-c option1
-c option2
-c option3
blablablabla
-c option4
-c option5
-c option6
How do I extract the following as blocks?
1)
-c option1
-c option2
-c option3
2)
-c option4
-c option5
-c option6
Thank you in advance for any help!
s = <<_
blablabla
-c option1
-c option2
-c option3
blablablabla
-c option4
-c option5
-c option6
_
s.scan(/(?:^ -c .*#$/)+/)
# => [
" -c option1\n -c option2\n -c option3 \n",
" -c option4\n -c option5\n -c option6\n"
]
or
s.split(/^(?! -c ).*/).drop(1)
# => [
" -c option1\n -c option2\n -c option3 \n",
" -c option4\n -c option5\n -c option6\n"
]
And here is the non-regexp version. A bit more typing, a bit easier to understand:
options = ->line{ line.strip.start_with? '-c' }
option_list = text.lines.chunk(&options)
.select{|is_option,_| is_option}
.map(&:last)