sh

scp: how to find out that copying was finished

这一生的挚爱 提交于 2019-12-01 04:44:25
问题 I'm using scp command to copy file from one Linux host to another. I run scp commend on host1 and copy file from host1 to host2. File is quite big and it takes for some time to copy it. On host2 file appears immediately as soon as copying was started. I can do everything with this file even if copying is still in progress. Is there any reliable way to find out if copying was finished or not on host2? 回答1: Off the top of my head, you could do something like: touch tinyfile scp bigfile tinyfile

sourcing env output

泪湿孤枕 提交于 2019-12-01 03:57:09
问题 I have some shell code I need to be debug, so I had the code dump its environment into a file env > env.txt and with my testing script I want to source it, test.sh: . ./env.txt echo $EXAMPLE echo $EXAMPLE2 the contents of env.txt are: EXAMPLE=sh /hello/command.sh EXAMPLE2=/just/some/path but, env does not put quotes around its values, which tends to cause a issue for $EXAMPLE, I get this error test.sh: /hello/command.sh: not found so clearly it is trying to run it instead of setting the

QProcess and shell : Destroyed while process is still running

帅比萌擦擦* 提交于 2019-12-01 03:56:32
问题 I want to launch a shell script with Qt. QProcess process; process.start(commandLine, QStringList() << confFile); process.waitForFinished(); if(process.exitCode()!=0) { qDebug () << " Error " << process.exitCode() << process.readAllStrandardError(); } else { qDebug () << " Ok " << process.readAllStrandardOutput() << process.readAllStrandardError(); } The result is : Ok : Result.... " "" QProcess : Destroyed while process is still running. This message does not appear every time. What is the

Run .bat in Linux environment

ε祈祈猫儿з 提交于 2019-12-01 03:41:58
问题 Is there any way to run .bat file in Linux environment? I have a couple of .bat files, the purpose of them is to call mvn install:install-file scripts. Thus nothing OS dependent is in the scripts. Thank you, 回答1: You can use wine or dosbox, but in general there is no known bat interpreter for linux. There are, however, implementations of various unix shells for windows, there's even a standard toolkit, Windows Services for UNIX (a.k.a. SUA), which include ksh implementation and many other

Testing against -n option in BASH scripts always returns true

蓝咒 提交于 2019-12-01 03:34:02
问题 I am writing a bash script, in which I am trying to check if there are particular parameters provided. I've noticed a strange (at least for me) behavior of [ -n arg ] test. For the following script: #!/bin/bash if [ -n $1 ]; then echo "The 1st argument is of NON ZERO length" fi if [ -z $1 ]; then echo "The 1st argument is of ZERO length" fi I am getting results as follows: with no parameters: xylodev@ubuntu:~$ ./my-bash-script.sh The 1st argument is of NON ZERO length The 1st argument is of

Function name valid in bash but not in sh [duplicate]

六眼飞鱼酱① 提交于 2019-12-01 03:32:47
This question already has an answer here: Allowed characters in Linux environment variable names 5 answers While playing around with bash and sh, I found out that the following is valid in bash: system.out.println () { printf "$1"; } but not in sh: sh: `system.out.println': not a valid identifier Why would this difference be there? Does the function defined above violate some convention (POSIX etc.) that causes this error? Noctua It's just the dots, you can't use dots in shell function names. Or any variable name, for that matter. I'll link you to this question: Allowed characters in linux

How to invoke octave script in unix shell

浪尽此生 提交于 2019-12-01 01:26:46
I have written an octave script file (.m) If anyone could point me out on how to run octave scripts on unix shell that would be really helpful. I do not want to execute the script by invoking octave program. I am new to unix and octave. Thanks in advance Yes, of course you can write an Octave program. Like so: $ cat octave_program #!/usr/bin/env octave ## Never forget your licence at the top of the files. 1; function [rv] = main (argv) disp ("hello world"); rv = 0; return; endfunction main (argv); $ chmod a+x octave_program # add executable permissions $ ./octave_program hello world There's a

Function name valid in bash but not in sh [duplicate]

时光总嘲笑我的痴心妄想 提交于 2019-12-01 00:16:50
问题 This question already has answers here : Allowed characters in Linux environment variable names (7 answers) Closed 5 years ago . While playing around with bash and sh, I found out that the following is valid in bash: system.out.println () { printf "$1"; } but not in sh: sh: `system.out.println': not a valid identifier Why would this difference be there? Does the function defined above violate some convention (POSIX etc.) that causes this error? 回答1: It's just the dots, you can't use dots in

POSIX compliant way to see if a function is defined in an sh script

与世无争的帅哥 提交于 2019-11-30 19:49:09
问题 I'm after THE proper way to see if a function is defined or not. A POSIX compliant way. __function_defined() { FUNC_NAME=$1 d=$(declare -f $FUNCNAME) if [ "${DISTRO_NAME_L}" = "centos" ]; then if typeset -f $FUNC_NAME &>/dev/null ; then echo " * INFO: Found function $FUNC_NAME" return 0 fi # Try POSIXLY_CORRECT or not elif test -n "${POSIXLY_CORRECT+yes}"; then if typeset -f ${FUNC_NAME} >/dev/null 2>&1 ; then echo " * INFO: Found function $FUNC_NAME" return 0 fi else # Arch linux seems to