I have a python script called spark.py. This scipt will be invoked using a shell script in Linux. The spark.py is like below: The shell.sh is like below In this shell script I am collecting the output of the spark.py as a variable. When I do so I am unable to see any print commands of the spark.py in the
Tag: shell
Linux shell temporary DNS
In a linux shell script, I want to change the dns address temporarily. To do this, I can insert temprary dns address into resolv.conf right after the shell run and remove it before the script ends. That’s it. But the problem is, all every other scripts also hit the address while the script is running. This is not what I
which is better? using cd and execute or using absolute path?
Suppose I would like to do some operation like touch/rmetc on a specific directory in shell script. Firstly, I can do cd to that directory and do it. Secondly, I can use absolute path to do that. My question is which one will be better in performance perspective? Which one is faster? Answer You can time it yourself: with this
Linux shell: my `expect` script doesn’t work as expected
I’ve got a simple script like below, read 2 numbers from command line and add them together: It runs, no problem. Then I wrote an expect script like below: Seems still it prompts to read from command line, after quite a long time, it ends. Where did I get wrong? Thanks. Answer You have to send the newlines as well,
Why I have to “source vitrualenvwrapper.sh” every time I open a new Terminal?
I use Zsh as my shell and I want to use vitrualenvwrapper. But when I close a terminal then open a new one, I have to “source virtualenvwrapper.sh” again then I can use virtualenvwrapper. Answer You need to put your script source-ing in some shell session initialization file e.g. /etc/zsh/zshrc (global) or ~/.zshrc (user-specific) will be read by zsh upon
linux bash script log output
Im having trouble getting output into my log file in my script. Backup runs successfully but the logfile is empty. WHen I run the script I get “Warning: Using a password on the command line interface can be insecure.” so at least that should be in a log file. (I am using a .key file) Answer Thats because, only error
Sort on specific part of filename in shell script
I have a list of files which I want to delete except 2 of the most recent ones. The files are named as “filename_dd_mm” for example “filename_19_05”. If I do It sorts them according to the day. What I want is to sort them by month first and then the day. Can someone please guide me to do this. P.S.
Does shell map restrict the key format?
Run the above code will get error: If I modify key=’dev’, it works. So, the key only can be a simple string? Answer You must declare the array associative first:
Shell: how to create a list variable from several args
I have shell script that runs a cli command with 3 or more args, i can’t specify in advance the number of args that will be passed to the script. i tried to replace Args=[$3,$4,….] by Args=[${@:3}] but the arguments are not comma-separated. Answer Change the value of IFS inside the command substitution and use $* instead of $@: The
How to take input in beginning of the program?
I am making a program which needs the user input in the beginning of the program if you don’t get my question i will give you an example: So, I want the input in the beginning of the program. I think the input will be stored in a variable. If yes, Then please tell me in which variable it is