logo
down
shadow

How to input parameters when running bash command with Scala


How to input parameters when running bash command with Scala

By : James Osgathorpe
Date : November 22 2020, 10:48 AM
This might help you Could someone give me an advice how to run command as below in scala ?
code :
import scala.language.postfixOps
import java.io.File
import scala.sys.process._

Seq("/usr/bin/mysql", "-u", "username", "-h", "mydb.host.rds.amazonaws.com", "-D", "dbname", "-p") #< new File ("/data/import.sql") !


Share : facebook icon twitter icon
Running a bash command with multiple lines of input via ssh

Running a bash command with multiple lines of input via ssh


By : user3425502
Date : March 29 2020, 07:55 AM
wish of those help To script a command and send it multiple lines of input you can use a here document.
code :
ldapmodify -h server.example.com -p 1389 -w '1234' -D "cn=Directory\ Manager" -a <<INPUT
dn:ou=test1,dc=example,dc=com 
objectclass:top 
objectclass:organizationalUnit
ou:test1
INPUT
ssh user@host.name ldapmodify -h server.example.com -p 1389 -w '1234' -D "cn=Directory\ Manager" -a <<INPUT
dn:ou=test1,dc=example,dc=com 
objectclass:top 
objectclass:organizationalUnit
ou:test1
INPUT
Bash script fails when running command with embedded quotes (source parameters)

Bash script fails when running command with embedded quotes (source parameters)


By : Joel Hilsenrath
Date : March 29 2020, 07:55 AM
wish help you to fix your issue Embedding quotes in a string does not escape the wrapped characters; they are just literal characters in the value. You need to use arrays for this:
code :
cmd=avconv
args=(-re -i /home/pi/test.mp3 -c:a libmp3lame -content_type audio/mpeg -b:a "$stream_bitrate" -legacy_icecast "$icecast_legacy")

stream_parameters=(-ice_name "$icecast_show" -f mp3)

icecast_setup="icecast://$icecast_user:$icecast_password@$icecast_server:$icecast_port$icecast_mount_url"

test_cmd="$start_cmd $stream_parameters $icecast_setup"
echo "Testing command: $cmd ${args} ${stream_parameters[@]} $icecast_setup"

# Run command
"$cmd" "${args[@]}" "${stream_parameters[@]}" "$icecast_setup"
Build a bash command with conditional parameters and cuote parameters

Build a bash command with conditional parameters and cuote parameters


By : Tanmay Shrivastava
Date : March 29 2020, 07:55 AM
I wish did fix the issue. You cannot safely and reliably store multiple arguments in a single string; you need to use arrays; this is their intended use case. Make sure to initialize any arrays that won't be used, so that they "disappear" when expanded.
code :
# If A is undefined, "${A[@]}" is an empty string.
# But if A=(), then "${A[@]}" simply disappears from the command line.
A=()
B=()
A1=()
A2=()

case $something in

BAYES)
    class="weka.classifiers.bayes.BayesNet"
    A=(-D -Q weka.classifiers.bayes.net.search.local.K2 -- -P 1 -S BAYES -E)
    B=(weka.classifiers.bayes.net.estimate.SimpleEstimator -- -A 0.5);;
LOGISTIC)
    class="weka.classifiers.functions.Logistic"
    A=(-R 1.0E-8 -M -1 -num-decimal-places 4);;
SIMPLELOG)
    class="weka.classifiers.functions.SimpleLogistic"
    A=(-I 0 -M 500 -H 50 -W 0.0) ;;
SMO)
    class="weka.classifiers.functions.SMO"
    A=(-C 1.0 -L 0.001 -P 1.0E-12 -N 0 -V -1 -W 1 -K)
    A1=(weka.classifiers.functions.supportVector.PolyKernel -C 250007 -E 1.0) ;;
IBK)
    class="weka.classifiers.lazy.IBk"
    A=(-K 1 -W 0 -A)
    A1=(weka.core.neighboursearch.LinearNNSearch -A)
    A2=(weka.core.EuclideanDistance -R first-last);;
KSTAR)
    class="weka.classifiers.lazy.KStar"
    A=(-B 20 -M a) ;;
esac
java -Xmx"$mem"m -cp "$WEKA_INSTALL_DIR/weka.jar" \
  "$class" -s "$i" -t "$file" "${A[@]}" "${A1[@]}" "${B[@]}" "${B1[@]}"
Command not found when running Bash script, but works when running command directly

Command not found when running Bash script, but works when running command directly


By : akmalizhar
Date : March 29 2020, 07:55 AM
it should still fix some issue By default, shell functions are only available in the shell they were defined in; they're not inherited by subprocesses. Your .bash_profile is only run by the login shell, not shells that run as subprocesses (e.g. to run scripts).
code :
letsencrypt_webfaction() {
    PATH="$PATH:$GEM_HOME/bin" GEM_HOME="$HOME/.letsencrypt_webfaction/gems" RUBYLIB="$GEM_HOME/lib" ruby2.2 "$HOME/.letsencrypt_webfaction/gems/bin/letsencrypt_webfaction" "$@"
}
Java running bash command while feeding it input and getting output

Java running bash command while feeding it input and getting output


By : margpete
Date : March 29 2020, 07:55 AM
I wish did fix the issue. You must use getInputStream() and getOutputStream() on the process to communicate it, see the javadocs.
If you do not read all data from the process, it might hang and even deadlock. For a short introduction on common problems, see this blog post. At the very least, you should be reading all data from the process output.
Related Posts Related Posts :
  • How to reaload scala application after code change using actors and sbt
  • akka non-blocking BoundedMailbox
  • Why are constructor parameters made into members for case classes?
  • Higher order tail recursive function needs to terminate early
  • How can I reusably filter based on type in Scala?
  • Why does Scala sbt update every time I start it from command prompt?
  • Recommended Scala io library
  • Thread-safely transforming a value in a mutable map
  • Why does chaining match expressions does not compile?
  • Ebean not persisting foreign keys
  • Difference between def m(p: T forSome {type T} and def m1(p:Any), is there any ? Explanation needed based on Scala Langu
  • macro does not find out enclosing vals
  • Spark : how to run spark file from spark shell
  • Flattening a list of lists to a set with exceptions in scala
  • flatMap implementation in Scala
  • Confused about a few lines code in a scala official document page
  • Location header is lost if max-redirects > 1
  • Controller Spec is using FakeApplication, but can't load test configuration
  • Scala code analyzer targets case variable names that are identical to the outer matched varables - "suspicous shado
  • Why does authorize directive execute after the code it's supposed to protect?
  • Scala. Checking if a Type is Comparable
  • Does having a private constructor on a value class negate the benefits of a value class?
  • How to transform submitted json in Play 2.0?
  • Scala warning match may not be exhaustive
  • Pure not a member of objective Promise in PlayFramework
  • How to unmarshal POST params and JSON body in a single route?
  • Spark:How to use join method?
  • is client thread-safe in Twitter Finagle
  • Why is the method accepts only one argument?
  • Scala Play 2.3 Working with gCloud Storage - any libs to go async?
  • spray.io strange get/delete/detach directives behavior
  • SBT cannot resolve class declared in src/main/scala in a src/test/scala test class
  • Scala typeclass without function argument
  • Configuring actor behavior using typesafe Config and HOCON
  • Scalatra: Migrating Jersey Filters to Scalatra
  • Compilation error when using Scaldi
  • Scalac hanging in phase typer
  • how to have different source code when cross-compiling Scala with sbt? (changes in MurmurHash)
  • How to set different scalacOptions per Scala version when cross-compiling using Build.scala?
  • Possible Bug in JDBC?
  • Is there a Scala compiler flag to warn when tail recursion is applied without annotation?
  • scala case class put methods in companion object?
  • multiproject sbt doesn't generate file structure
  • Scala "multilevel" abstract class / abstract objects replacement
  • Scala, getting the type parameters of a KList as an HList
  • Why does Play refuse form reporting "Cannot resolve method apply with such signature: Missing arguments"?
  • How to split string with trailing empty strings in result?
  • Scala group by list of list and subtracts grouped values
  • Scala - Creating a function to produce Unary string or integer values
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org