sh

How to use getopt with this several values?

吃可爱长大的小学妹 提交于 2019-12-11 18:53:56
问题 I try to achieve a script with multi options. I started with the doc, get some errors, went to the browser. Read some links and find this on SO : Using getopts in bash shell script to get long and short command line options. So I read it and rewrote my script. I made a mistake somewhere. Where am I wrong ? SH #!/bin/sh TEMP=`getopt -o vfts: --long verbose,format,type,style: \ -n 'opt2' -- "$@"` if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi eval set -- "$TEMP" VERBOSE=false

R/Shiny: Download multiple files (zip) from a folder on the server

丶灬走出姿态 提交于 2019-12-11 17:17:28
问题 I would like to create a zip archive (containing several xlsx files) and save it locally. The files are stored in a folder on the server side. The user selects the files to zip using a checkboxInput. Here the code for the checkbox: get.files <- reactive({ list.files("output_file/") }) obsList <- list() output$links_list <- renderUI({ lapply(as.list(1:length(get.files())), function(i) { btName <- get.files()[i] # creates an observer only if it doesn't already exists if (is.null(obsList[[btName

Using for loop to pass arguments to command

放肆的年华 提交于 2019-12-11 16:38:37
问题 I have below command that produce this output Command: oozie job -info 0007218-170910003406158-oozie-oozi-W | grep job | awk '{print $3}' | cut -c1-23 | sed 's/job/application/' Output: application_1505017974932_23474 application_1505017974932_23478 application_1505017974932_23477 application_1505017974932_23473 application_1505017974932_23475 application_1505017974932_23471 application_1505017974932_23469 application_1505017974932_23476 application_1505017974932_23472 application

SSH session - why bash FOR loop is not even showing value and also using LOCAL machine

匆匆过客 提交于 2019-12-11 15:37:32
问题 I'm running this SSH command: ssh -p 2001 -q root@12.13.14.15 \ " echo echo Now On Target Server, I see ls -l /tmp/Folder-1.1.0.1053/* for v in A B C ; do echo === $v=== done echo for f in /tmp/Folder-1.1.0.1053/* ; do echo File is == $f done " and it's printing this: Now On Target Server, I see -rw------- 1 root root 159790 Jan 23 17:03 /tmp/Folder-1.1.0.1053/file1-1.8.30.tar.gz -rw------- 1 root root 116731 Jan 23 17:03 /tmp/Folder-1.1.0.1053/file2-2.7.49.tar.gz === === === === === === File

Executing screen command from Java

别来无恙 提交于 2019-12-11 15:11:55
问题 I am using the following code to execute an SH file in Linux Runtime.getRuntime().exec(new String[] { "/bin/sh", "-c", file.getPath() }); This code works however I can't use the screen command in the SH file when executing it from Java, I get this error Must be connected to a terminal. So is it possible to "connect" java to a terminal? I would like to be able to also view this screen when I connect via SSH so I think it has to be connected to the terminal that is shown when you SSH into the

How to change argv[0] value using bash/shell? [duplicate]

馋奶兔 提交于 2019-12-11 15:00:38
问题 This question already has answers here : How to change argv[0] value in shell / bash script? (3 answers) Closed 2 months ago . The script should be able to change argv[0] value in shell / bash script. I found on an older post but couldn't really understand what it is doing. Could someone please explain how the line works: sh -c ". '$0'" argv0new "$@" Also is test ".$INNERCALL" meant to be a variable ? Original question: How to change argv[0] value in shell / bash script? #! /bin/bash # try

BASH: Read all files in a directory recursively, includinging symbolic links

十年热恋 提交于 2019-12-11 14:07:38
问题 I got this tidy script from someone: find ../Classes -name \*.cpp -print which simply loops a directory, and prints all files recursively. However, it doesn't follow symlinks. All I can find online is: find ../Classes -name \*.cpp -type l -print But, since the directory is the symlink, not the files, it outputs nothing. How can I solve that? 回答1: Tell find to follow symlinks with -L find -L ../Classes -name \*.cpp -print 来源: https://stackoverflow.com/questions/16693828/bash-read-all-files-in

My mac osx launched plist won't run

僤鯓⒐⒋嵵緔 提交于 2019-12-11 11:41:49
问题 it looks like it loads but has a status of 1 when using launchctl list and using launchctl start ... it says No such Process... i have it saved in /Users/IMG/Library/LaunchAgents. The sh script runs fine. the logging doesn't show anything - no file created.. I am very new to plist so please forgive ignorance. <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key

bin sh script - “(” unexpected [duplicate]

人盡茶涼 提交于 2019-12-11 10:52:58
问题 This question already has answers here : Difference between sh and bash (11 answers) Closed 7 months ago . What is wrong with this script? #!/bin/sh for file in *.p; do awk -f get_p.awk "$file" > "$file"er; done awk -f phase-comp.awk file1 file.per # výpočet fází paste <(awk '{print $1}' output1) <(awk '{print $2}' file1) > out The error is: 5: skript: Syntax error: "(" unexpected When I write command separately to terminal. It works well. Thank you 回答1: The problem is your shebang: #!/bin/sh

piping output of process to sh while loop?

ぐ巨炮叔叔 提交于 2019-12-11 09:39:20
问题 I'm trying to loop over the output of a Perl process, line by line, within a while loop. However, I'm having difficulty with the syntax. I tried this, but got an "ambiguous redirect" error: #!/bin/sh while read line; do echo "$line" # do stuff with $line done < $(perl process.pl) ./script.sh : line 6: $(perl process.pl): ambiguous redirect For instance, one (inefficient) solution would be: #!/bin/sh tmpFile=/tmp/tmpFile.txt perl process.pl > $tmpFile while read line; do echo "$line" # do