Is there a simple method for calling shell command line arguments (like ls or pwd) from within python interpreter?
2579
How do you call an external command (as if I'd typed it at the Unix shell or Windows command prompt) from within a Python script?
84470
Suppose I have a bash shell script called Myscript.sh that need one argument as input.  But I want the content of the text file called text.txt to be that argument.  I have tried this but it does not work:  cat text.txt | ./Myscript.sh   Is there a way to do this?
37477
There're way too many articles/resources on the web that teaches people HOW to set the environment variable PATH so that they can use the short hand of java or python etc instead of the absolute path in command line interface.  What I'm interested to know is that what's behind the scene when we type in the command and hit enter (similar to ).  Here is my guess:   read the command (parse/preprocess stdin to get the right arguments $@) command lookup command execution (program started, consume memory, stdout/stderr to shell) re-render the emulator by relevant environment variables (e.g. $PS#, $PROMPT, etc)   The part I want to figure out most is the command lookup. Obviously, the $PATH is consumed by some background function and separated by : / ;as delimiters, then what happened? Do we use a hash table (key: basename of the file, value: absolute dirname of the file) to store the binary files under those PATHs, or some other hooks?   NOTE: I originally thought it was hash table as I can use [ -z hash [command] ] to check if a command is available in current env, but when I use hash | grep python I get nothing from the output while which python works as anticipated. (I think the mechanism might be shell specific, but I want to get more insights into it.)
73573
How can I create an empty file from the command line?
68174
I think I remember a command line utility that did this, but I can't remember what it's called and a few Google searches turn up nothing.
94743
I have a bash script like this  export pipedargument="| sort -n" ls $pipedargument   But it gives the error  ls: |: No such file or directory ls: sort: No such file or directory   It seems to be treating the contents of "| sort -n" as just an argument passed to ls.   How can I escape it so that it's treated as a regular piped command?   I'm trying to conditionally set the $pipedargument. I guess I could just conditionally execute different versions of the command but still wondering if there's a way to make this work like above?
67692
INPUT_FILE=`ls -rt $MY_DIR/FILE.*.xml | head -1 | xargs basename`   I wanted to execute the second command (head -1) only if the first command is successful. How do I improve this command?
108395
All I wrote in the interpreter was as follows:  &gt;&gt;&gt; print "Hello, World!"   File "&lt;stdin&gt;", line 1     print "Hello, World!"                         ^ SyntaxError: invalid syntax   How did I even get an error? All I tried to do was run a print command.
105902
I like to encapsulate commands within shell-functions using the same name. But to avoid the shell-function calling itself recursively, I specify the complete path of the command as the following example:  less() {     test 0 -lt $# &amp;&amp; echo -ne "\e]2;$@\a\e]1;$@\a"     # Window title     /usr/bin/less -i -rS --LONG-PROMPT --shift 5 "$@" }   But for some commands, I do not want to specify the path because it may change. I would prefer to use $PATH.  For instance, my following attempt failed to call mvn command using backslash: \mvn  mvn()  # colorizes maven output {         \mvn "$@" 2&gt;&amp;1 | #here: the shell-function recursively calls itself indefinitely         sed -u '                                                  s/^\[ALL\].*/\o033[1;37m&amp;\o033[0m/   s/^\[FATAL\].*/\o033[1;31m&amp;\o033[0m/   s/^\[ERROR\].*/\o033[1;31m&amp;\o033[0m/ s/^\[WARNING\].*/\o033[1;33m&amp;\o033[0m/    s/^\[INFO\].*/\o033[1;37m&amp;\o033[0m/   s/^\[DEBUG\].*/\o033[1;36m&amp;\o033[0m/   s/^\[TRACE\].*/\o033[1;32m&amp;\o033[0m/' }   What is the best way to bypass this issue?   Please do not suggest to use a different shell-function name.  (I usually use bash but I am interested about other shell solutions.)
53288
myscript [-a a-arg] [-c c-arg] [-b] [-e] somedirectory   Given that I want my shell script be invoked at the command line using the above parameters - where [these brackets] denote that they are optional - what is the best method to parse them?
115482
How exactly using VB6 can I can call any Windows shell command as you would from the command-line?  For example, something as trivial as:  echo foo
100353
How can you do the equivalent of piping stdout to 'export'?  For background, I have a non-shell script that generates environment variables like so:  DATABASE_URL='someurl' MAIL_KEY='key' REDIS_URL='redis connection string'   I would like to take that output and execute it, something like: generate-env | xargs export  Unfortunately, export isn't a binary, and neither is eval. I would prefer not to have to write my output to a file and run it with source. Is this even possible?
23979
I've got this situation:  ./ ./myscript.sh ./arguments.txt ./test.sh   Inside myscript.sh, I have to run the file test.sh, passing to it the arguments contained inside arguments.txt.  myscript.sh is:  arguments=$(cat arguments.txt) source test.sh $arguments   This works well if if arguments.txt contains at most one argument:  firstargument    The substitution is:  ++ source test.sh 'firstargument'   But the problem is with two or more arguments. It does this:  ++ source test.sh 'firstargument secondargument'   Also, I don't know in advance the number of arguments inside arguments.txt. There can be zero or more.
42444
How can I call an external program with a python script and retrieve the output and return code?
60843
How do I call shell commands from inside of a Ruby program? How do I then get output from these commands back into Ruby?
2410
I wish to have long and short forms of command line options invoked using my shell script.  I know that getopts can be used, but like in Perl, I have not been able to do the same with shell.  Any ideas on how this can be done, so that I can use options like:  ./shell.sh --copyfile abc.pl /tmp/ ./shell.sh -c abc.pl /tmp/   In the above, both the commands mean the same thing to my shell, but using getopts, I have not been able to implement these?
11466
What command can be used to check if a directory exists or not, within a Bash shell script?