I have got an error , error: unrecognized arguments: \ , while running below commands in Rasa stack bot bulding.
python -m rasa_core.run -d models/dialogue -u models/nlu/current \
--port 5002 --credentials credentials.yml
\ is used on Linux terminals to break up a command in multiple lines, e.g.:
copy file1.txt \
file2.txt
It seems that your terminal does not recognise \ properly. Are you using Windows as operating system?
On Windows you have to use ^ to break it in multiple lines, e.g copy file1.txt file2.txt becomes:
copy ^
file1.txt ^
file2.txt
If this also does not work you can also remove the \ and have the command in one line:
python -m rasa_core.run -d models/dialogue -u models/nlu/current --port 5002 --credentials credentials.yml
\ is used as notation for continuation of a command in Linux. Usually used when the command is very long, so that command is readable. In windows, you can execute without the \ character, it should work
Related
I have a bash script like below. First it will take sorted.bam files as input and use "stringtie" tool give each sample gtf as output. Then path for each sample gtf will be given into mergelist.txt. and then use "stringtie merge" on them to get "stringtie_merged.gtf".
I totally have 40 sorted.bam files.
for sample in /path/*.sorted.bam
do
dir="/pathto/hisat2_output"
dir2="/pathto/folder"
base=`basename $sample '.sorted.bam'`
"stringtie -p 8 -G gencode.v27.primary_assembly.annotation_nochr.gtf -o ${dir2}/stringtie_output/${base}/${base}_GRCh38.gtf -l ${dir2}/stringtie_output/${base}/${base} ${dir}/${base}.sorted.bam; ls ${dir2}/stringtie_output/*/*_GRCh38.gtf > mergelist.txt; stringtie --merge -p 8 -G gencode.v27.primary_assembly.annotation_nochr.gtf -o ${dir2}/stringtie_output/stringtie_merged.gtf mergelist.txt"
done
I separated the commands with ; After running the script on all sorted.bam files and after completing the job I see that mergelist.txt has paths only for 33 sample gtf's. Which means the path for other 7 sample gtfs is missing in merge list.txt.
Is Separating the commands with ; right one or is there any other way?
The script should use one command first and with the output the paths need to be given in the text file and then use the other command.
You haven't separated the commands with semi-colons; you've invoked a single command that has semi-colons embedded in it. Consider the simple script:
"ls; pwd"
This script does not call ls followed by pwd. Instead, the shell will search the PATH looking for a file named ls; pwd (that is, a file with a semi-colon and a space in its name), probably not find one and respond with an error message. You need to remove the double quotes.
What's wrong with multiple lines, as you already have more than one line:
dir="/pathto/hisat2_output"
dir2="/pathto/folder"
for sample in /path/*.sorted.bam ;do
base=$(basename ${sample} '.sorted.bam')
stringtie -p 8 -G gencode.v27.primary_assembly.annotation_nochr.gtf -o ${dir2}/stringtie_output/${base}/${base}_GRCh38.gtf -l ${dir2}/stringtie_output/${base}/${base} ${dir}/${base}.sorted.bam
ls ${dir2}/stringtie_output/*/*_GRCh38.gtf > mergelist.txt
stringtie --merge -p 8 -G gencode.v27.primary_assembly.annotation_nochr.gtf -o ${dir2}/stringtie_output/stringtie_merged.gtf mergelist.txt
done
Anyway, I don't see the point in having the second stringtie command inside the loop, it should work fine just after.
If stringtie is able process STDIN you might get away without the mergelist.txt by using:
stringtie --merge -p 8 -G gencode.v27.primary_assembly.annotation_nochr.gtf -o ${dir2}/stringtie_output/stringtie_merged.gtf <<< $(echo ${dir2}/stringtie_output/*/*_GRCh38.gtf)
you should double quote your variables and use $( command ) instead backticks
base=$( basename $sample '.sorted.bam' ) :
you have a space in filenames??
prefer:
base=$( basename "$sample.sorted.bam" ) # with or without space
if you have spaces, you must double quote:
stringtie -p 8 \
-G gencode.v27.primary_assembly.annotation_nochr.gtf \
-o "$dir2/stringtie_output/$base/$base_GRCh38.gtf" \
-l "$dir2/stringtie_output/$base/$base" \
"$dir/$base.sorted.bam"
ls "$dir2"/stringtie_output/*/*_GRCh38.gtf > mergelist.txt
...
I'd like to execute the following command for several files in same repository in linux:
../../../../../openSMILE-2.1.0/SMILExtract -C ../../../../../openSMILE-2.1.0/config/IS13_ComParE.conf -I inputfilename.wav -D outputfilename.csv
there are several files (named 1.wav, 2.wav, 3.wav) in the directory and if I execute
../../../../../openSMILE-2.1.0/SMILExtract -C ../../../../../openSMILE-2.1.0/config/IS13_ComParE.conf -nologfile 1 -noconsoleoutput 1 -I 1.wav -D 1.csv
it outputs 1.csv.
How can I create 1.csv, 2.csv, 3.csv, .. by executing just one single command in linux? (or do I have to make .sh file?)
It's probably cleaner to put the following to a script, but you can type it directly into the bash command line as well:
#! /bin/bash
for file in *.wav ; do
prefix=${file%.wav} # Remove from the right.
../../../../../openSMILE-2.1.0/SMILExtract \
-C ../../../../../openSMILE-2.1.0/config/IS13_ComParE.conf \
-I "$file" -D "$prefix".csv
done
Quite new to bash - I'm trying to store the output of my /usr/bin/time command into the TIME_INFO variable, which works with the below setup... however I would also like to be able to store the output of some of the other nested commands (such as /usr/local/bin/firejail or ./program) to other variables. Currently if there is a runtime exception in ./program it'll also go to the TIME_INFO variable.
TIME_INFO=$( /usr/bin/time --quiet -f "%e-%U-%S-%M-%x" 2>&1 \
timeout 5s \
/usr/local/bin/firejail --quiet --cgroup=/sys/fs/cgroup/memory/group1/tasks --profile=java.profile \
./program < test.in > test.out )
Is there any way to accomplish separating outputs of multiple nested commands?
Thanks in advance!
One way to do this is to inject a shell in the call chain and make it responsible for modifying stderr for its subprocesses:
time_info=$( /usr/bin/time --quiet -f "%e-%U-%S-%M-%x" 2>&1 \
sh -c '"$#" 2>"$0"' test.err \
timeout 5s \
/usr/local/bin/firejail \
--quiet --cgroup=/sys/fs/cgroup/memory/group1/tasks --profile=java.profile \
./program < test.in > test.out )
# read your content back into a shell variable
error_text=$(<test.err)
The pertinent change here is sh -c '"$#" 2>"$0", which runs its arguments as a command, with stderr redirected to the filename passed in $0 -- which is populated from the string immediately following code passed with sh -c.
Note that I modified the case of the TIME_INFO variable per POSIX guidance specifying all-caps names for variables with meaning to the shell or OS, and reserving names with at least one lower-case character for other purposes.
I am very new to programing, especially in bash.
I often run the same long command filled with many arguments each day but with different file names and one other argument, the bulk of the string remains the same. This is the case for Clonezilla server.
I want to be able to run a script that only asks for the for the portions I want to change, then substitutes those values into the original string and pass it along to the shell.
For example:
I have a set of file names: a.img b.img c.img
the command I run: drbl-ocs -b -g auto -e1 auto -e2 -r -x -j2 -sc0 -p poweroff --clients-to-wait <number value here> -l en_US.UTF-8 startdisk multicast_restore <name of file> nvme0n1
My goal is to be able to type: sudo sh myscript.sh arga argb
where "arga" is a number that replaces <number value here> and "argb" replaces <name of file> in the above string.
Thanks for any help!
The command line arguments to a script can be found in the positional parameters, parameters whose names are positive integers.
#!/bin/sh
drbl-ocs -b -g auto -e1 auto -e2 -r -x -j2 -sc0 \
-p poweroff --clients-to-wait "$1" -l en_US.UTF-8 \
startdisk multicast_restore "$2" nvme0n1
This question already has answers here:
Difference between single and double quotes in Bash
(7 answers)
Closed 8 years ago.
I have a bash function in my .bash_profile that is not returning results to the terminal.
When I run the command as normal via the CLI results are returned.
ldap_check_cleaup ()
{
ldapsearch -LLL -h itdsvbms.SomeDomain.org -p 389 \
-D "uid=SomeUser,o=SomeDomain.org" -w SomePassWord -b "ou=People,o=SomeDomain.org" \
-s sub '(&(ReservedRMAliases=$1)(!(RMid=*))(RMAliasUpdateDate=12/01/2012 19:02:00)(RMAliasStatus=IN)(status=IN))' | \
tee /dev/tty
}
running ldap_check_clenaup TestRecord returns no output when executed from the bash prompt. TestRecord does exist and when the following command is run from the CLI, the correct record is returned:
ldapsearch -LLL -h itdsvbms.SomeDomain.org -p 389 -D "uid=SomeUser,o=SomeDomain.org" \
-w SomePassWord -b "ou=People,o=SomeDomain.org" \
-s sub '(&(ReservedRMAliases=TestRecord)(!(RMid=***))(RMAliasUpdateDate=12/01/2012 19:02:00)(RMAliasStatus=IN)(status=IN))' | \
tee /dev/tty`
The lack of out put only happens when I try to use this ldapsearch and the arguments as a bash function.
I think this may be related to using ' instead of " for the attribute (!(RMid=*)) but I am unsure, please help.
You need to use double-quotes around the argument that contains $1. Variable interpolation is not performed inside single-quoted strings.