batch tslint on several lines - batch-processing

I launch a batch that contains a tslint command
tslint -c ../tslint.json --project tsconfig.json --out output.txt --format msbuild -e '**/bin/Debug/**' -e '**/fonts/**' -e '**/images/**' -e '**/Scripts/**' -e '**/typings/**' -e 'file1.ts' -e 'file2.ts' -e 'file3.ts' -e 'file3.ts' -e 'file4.ts'
…
unfortunately I want to exclude a lot of files and it is not easy to read so I would like to read the same file but with the possibility of being able to go to the line and write Something on that form:
tslint -c ../tslint.json --project tsconfig.json --out output.txt --format msbuild
-e '**/bin/Debug/**'
-e '**/fonts/**'
-e '**/images/**'
-e '**/Scripts/**'
-e '**/typings/**'
-e 'file1.ts'
-e 'file2.ts'
-e 'file3.ts'
-e 'file3.ts'
-e 'file4.ts'
Do you know how to do this please?

Here's my comment as an answer.
You could try escaping the line returns with carets, ^, including a space before each:
tslint --config ../tslint.json --project tsconfig.json --out output.txt --format msbuild ^
--exclude '**/bin/Debug/**' ^
--exclude '**/fonts/**' ^
--exclude '**/images/**' ^
--exclude '**/Scripts/**' ^
--exclude '**/typings/**' ^
--exclude 'file1.ts' ^
--exclude 'file2.ts' ^
--exclude 'file3.ts' ^
--exclude 'file4.ts'
Alternatively, start the individual lines with a space and finish each proceeding line with the caret, ^:
tslint -c ../tslint.json -p tsconfig.json -o output.txt -f msbuild^
-e '**/bin/Debug/**'^
-e '**/fonts/**'^
-e '**/images/**'^
-e '**/Scripts/**'^
-e '**/typings/**'^
-e 'file1.ts'^
-e 'file2.ts'^
-e 'file3.ts'^
-e 'file3.ts'^
-e 'file4.ts'
As it is unlikely that multiple spaces will be problematic to tslint, you could even try this:
tslint -c ../tslint.json^
-p tsconfig.json^
-o output.txt^
-f msbuild^
-e '**/bin/Debug/**'^
-e '**/fonts/**'^
-e '**/images/**'^
-e '**/Scripts/**'^
-e '**/typings/**'^
-e 'file1.ts'^
-e 'file2.ts'^
-e 'file3.ts'^
-e 'file4.ts'

Related

Can I build my PC file (Oracle Pro*c) conditionally inside of my application's make file?

I'm attempting to combine my makefiles so I can simply build once and it will precompile the pc file completely before continuing to build the application. This should be possible but for the life of me I cannot figure it out. Here is my makefile (for redhat 7).
COMPILEDATE = $(shell date)
COMPILE=g++ -std=c++11 -Wall -Wuninitialized -g
OSTYPE = $(shell uname)
LIBDIR=../../lib/
INC=../../include/
FILES=myProcess
OBJS= myProcess.o \
sqlStuff.o
O8P=$(ORACLE_HOME)
O8P=/u01/app/oracle/11.2.0/client_1
ORACLE_HOME=/u01/app/oracle/11.2.0/client_1
PROC_LINES=proc lines=yes code=ANSI_C iname=sqlStuff.pc parse=partial iname=sqlStuff include=. include=$(ORACLE_HOME)/precomp/public include=$(ORACLE_HOME)/rdbms/public include=$(ORACLE_HOME)/rdbms/demo include=$(ORACLE_HOME)/plsql/public include=$(ORACLE_HOME)/network/public
all: $(FILES)
compileInfo.o : FORCE
$(COMPILE) -c compileInfo.cpp -o $# -I$(INC) -DCDATE="\"$(COMPILEDATE)\"" -DBUILD="\"$(LSWBUILD)\""
FORCE :
%.o : %.cpp $(INC)myProcess.h
$(COMPILE) -c $< -o $# -I$(INC) -DCDATE="\"$(COMPILEDATE)\""
sqlStuff.o : sqlStuff.c
gcc -g -Wall -O -c -lclntsh -I. -I$(ORACLE_HOME)/precomp/public -I$(ORACLE_HOME)/rdbms/public -I$(ORACLE_HOME)/rdbms/demo -I$(ORACLE_HOME)/plsql/lib -I$(ORACLE_HOME)/network/lib
sqlStuff.c : sqlStuff.pc
$(PROC_LINES)
myProcess: $(OBJS) $(LIBDIR)libbase.a $(INC)myProcess.h sqlStuff.o
$(COMPILE) -o myProcess$(OBJS) -L$(LIBDIR) -lbase
clean:
rm -f $(FILES)
rm -f sqlStuff
rm -f sqlStuff.c
rm -f sqlStuff.lis
rm -f $(OBJS)
rm -f core
rm -f *.out
rm -f *.log
rm -f *.err
My fault, I didn't explain what the issue was:
I'm compiling in netbeans using this build command: ${MAKE} -f Makefile. The error is PCC-S-02015, unable to open include file on my object that is not being precompiled, sqlStuff.o
Looking at the gcc command under sqlStuff.o : sqlStuff.c, it looks to me that there should be a -o sqlStuff.o flag to tell gcc that the output should be written to sqlStuff.o instead of the default, which is a.out.
Best of luck.

Change the name of the CSV File Automatically

sqlcmd -S PC03 -d db_test -E -o "test\MyData.csv" ^
-Q "[test2]" ^
-W -w 999 -s","
I would like to change the name of the file into "20150512". The name of the file should be today's date.
I do not know how to do it.
Thanks!
try this to generate YYYYMMDD format output file. (append your filename)
Edited:
sqlcmd -S PC03 -d db_test -E -o c:\test-%datetime:~0,4%-%datetime:~4,2%-%datetime:~6,2%.csv
sqlcmd -S servername -d dbtest -E -o c:\asdf\%date:~0,10%.csv ^ -Q
"[dbname].[sp]" ^ -W -w 999 -s","

How to locate code in PHP inside a directory and edit it

I've been having problems with multiple hidden infected PHP files which are encrypted (ClamAV can't see them) in my server.
I would like to know how can you run an SSH command that can search all the infected files and edit them.
Up until now I have located them by the file contents like this:
find /home/***/public_html/ -exec grep -l '$tnawdjmoxr' {} \;
Note: $tnawdjmoxr is a piece of the code
How do you locate and remove this code inside all PHP files in the directory /public_html/?
You can add xargs and sed:
find /home/***/public_html/ -exec grep -l '$tnawdjmoxr' {} \; | xargs -d '\n' -n 100 sed -i 's|\$tnawdjmoxr||g' --
You may also use sed immediately than using grep -but- it can alter the modification time of that file and may also give some unexpected modifications like perhaps some line endings, etc.
-d '\n' makes it sure that every argument is read line by line. It's helpful if filenames has spaces on it.
-n 100 limits the number of files that sed would process in one instance.
-- makes sed recognize filenames starting with a dash. It's also commendable that grep would have it: grep -l -e '$tnawdjmoxr' -- {} \;
File searching may be faster with grep -F.
sed -i enables inline editing.
Besides using xargs it would also be possible to use Bash:
find /home/***/public_html/ -exec grep -l '$tnawdjmoxr' {} \; | while IFS= read -r FILE; do sed -i 's|\$tnawdjmoxr||g' -- "$FILE"; done
while IFS= read -r FILE; do sed -i 's|\$tnawdjmoxr||g' -- "$FILE"; done < <(exec find /home/***/public_html/ -exec grep -l '$tnawdjmoxr' {} \;)
readarray -t FILES < <(exec find /home/***/public_html/ -exec grep -l '$tnawdjmoxr' {} \;)
sed -i 's|\$tnawdjmoxr||g' -- "${FILES[#]}"

How to pass a bash variable into an sql file

I have a bash script to call a select in postgres. I would like to be able to pass a variable from the command line into the sql file.
sh myscript.sh 1234
#!/bin/bash
dbase_connect="psql -h server -U username dbase"
file="/tmp/$fname.csv"
sql="/home/user/sql_files/query.sql"
sudo bash -c "$dbase_connect -c -q -A -F , -f $sql -o $file"
The query can be as simple as:
select name from table where id = $1;
But I don't know how to call the $1 into the sql file. The actual query is much larger and I prefer to keep it out of the bash query itself because it is easier to maintain when called as a seperate .sql file.
you can use sed to insert parameter :
#!/bin/bash
dbase_connect="psql -h server -U username dbase"
file="/tmp/$fname.csv"
sql="/home/user/sql_files/query.sql"
tmp="home/user/sql_files/query.sql.tmp"
s="s/\$1/$1/g"
cat $sql | sed $s > $tmp
sudo bash -c "$dbase_connect -c -q -A -F , -f $tmp -o $file"
rm -f $tmp

ssh on remote server to kill process, pushd script folder and execute the script is not wor

I have a requirement to kill remote process of specific patter, pushd the path to startup and execute the script.
I tried so far with
pid=$(ssh -q username#virt ps -ef|grep $APP|grep $PORT|awk '{print $2}')
ssh -q username#virt kill -9 $pid
ssh -q username#virt "find /shared/local/path1/app -name "start_app*" -exec grep -nl "9122" {} \;| xargs -0 -I '{}' bash -c 'pushd $(dirname {});bash {};'"
When I execute above command kill processing is working fine. The final step to find for scriptfile and execute script by pushing the folder to the path is not working.
For some reason the pushd is not working fine.
The command on the local server do work fie with
find /shared/local/path1/app -name "start_app*" -exec grep -nl "9122" {} \;| xarg -0 -I '{}' bash -c 'pushd $(dirname {});bash {};'
Please help a more effective solution to accomplish this task.
You have an error in the quotes here:
ssh -q username#virt "find /shared/local/path1/app -name "start_app*" -exec grep -nl "9122" {} \;| xargs -0 -I '{}' bash -c 'pushd $(dirname {});bash {};'"
Try this in stead:
ssh -q username#virt "find /shared/local/path1/app -name 'start_app*' -exec grep -nl '9122' {} \;| xargs -0 -I '{}' bash -c 'pushd \$(dirname {});bash {};'"