Posts

Showing posts with the label bash

shell script within Conda env can't execute mkdir

shell script within Conda env can't execute mkdir We are on an Ubuntu system running conda. Within an environment (python2, pandas, other packages) we are trying to run a shell script that: 1. creates dir (mkdir) 2. runs executables the path to which are in PATH (.bashrc) Neither of these are working, and I imagine is a config error on our part. Here are the errors: mkdir: cannot create directory ‘ResultsSparCC/Resamplings2’: No such file or directory mkdir: cannot create directory ‘ResultsSparCC/Bootstraps’: No such file or directory ./sparccWrapper.sh: line 31: ResultsSparCC/sparcc.log: No such file or directory Traceback (most recent call last): File "/home/charlesh/binf/src/sparcc/MakeBootstraps.py", line 9, in <module> from analysis_methods import permute_w_replacement File "/home/binf/src/sparcc/analysis_methods.py", line 7, in <module> from pandas import DataFrame as DF ImportError: No module named pandas However, pandas is installed i...

Strange behavior of vim color inside screen with 256 colors

Strange behavior of vim color inside screen with 256 colors I was trying to make the syntax highlighting (with 256 colors) of vim work inside screen , which is running inside gterm . vim screen gterm It works quite fine in the beginning. What I mean by "in the beginning" is, after I start screen , and enter vim , the colors look fine, and there are really 256 colors. screen vim But after a while (I don't know exactly how long) the colors automatically change back to an appearance as if there are only 8 (or 16?) colors. For example, after this has already occurred, if I enter the command hi Comment ctermfg=68 inside vim , the comments appear to be "pure" green; however, if I open another vim outside screen (in the same terminal), then with the same command the comments appear to be a "yellowish" green. vim vim The following is my .screenrc settings related to color: attrcolor b ".I" defbce "on" termcapinfo xterm 'Co#256:AB=E[48...

Bash Script is not working [on hold]

Bash Script is not working [on hold] When i am writing the script like this #!/bin/sh pidof MX-CM48 | xargs kill if [ -f /home/root/MX-CM48NEW ]; then mv /home/root/MX-CM48NEW /home/root/MX-CM48 chmod 777 /home/root/MX-CM48 fi cd /home/root ./MX-CM48 & the script is working. but when i am trying to write it like this: #!/bin/sh NEW_FILE="/home/root/MX-CM48NEW" OLD_FILE="/home/root/MX-CM48" PATH="/home/root" APP_NAME="MX-CM48" pidof $APP_NAME | xargs kill if [ -f $NEW_FILE ]; then mv $NEW_FILE $OLD_FILE chmod 777 $OLD_FILE fi cd $PATH ./$APP_NA...

Xcode/Swift: How to add extra argument to a bash execution

Xcode/Swift: How to add extra argument to a bash execution I have this Code: func syncShellExec(path: String?) { let script = [path!] let process = Process() let outputPipe = Pipe() let filelHandler = outputPipe.fileHandleForReading process.launchPath = "/bin/bash" process.arguments = script process.standardOutput = outputPipe . . . In Swift I call it this way: self.syncShellExec(path: Bundle.main.path(forResource: "initial", ofType: "command")) Now I want to add an Extra argument for the script itself (using Functions within the Bashscript). In Terminal it would be like this: /usr/bin/bash initial.command Do_My_Function How to add this to the process? 1 Answer 1 You can add a “variadic parameter” to your Swift function, and append the arguments to process.arguments : process.arguments...

How to write a zsh alias that calls a subshell?

How to write a zsh alias that calls a subshell? I am trying to create a zsh alias which would do the equivalent of: zsh cat `which some_command` In bash that is not achievable with an alias so I had a function in my ~/.bashrc with the following content: ~/.bashrc function catw { cat `/usr/bin/which "${1}"` } I moved the function to ~/.zhrc without changes and it works, but while in bash it executes immediately with zsh I am getting a several seconds delay before the cat command actually runs. ~/.zhrc bash zsh cat Is there a way to have this as a more efficient zsh alias? If not then why does the function takes longer to execute? Can I change anything in the function to make it work as fast as in bash ? zsh bash I tried your function in my zsh and catw ldd was pretty much instantaneous. Do you get the same lag when you repeat the command multiple times? – that other guy Jul 1 at 4:44 ...

git fetch upstream master not working, what is going wrong?

Image
git fetch upstream master not working, what is going wrong? So I'm wondering if there is a problem with the upstream master? I'm not sure if this error happens when everything is updated already or if it's something different. I have added upstream link with no problem, using $ git remote add upstream https://github.com/udacity/course-collboration-travel-plans.git just want to sync with the master now git remote add <name> <url> does not probe to see if there is a server at <url> that can access a Git repository. Are you sure your <url> is correct? (Hint: what happens if you click on the URL in your question?) – torek Jul 1 at 3:27 git remote add <name> <url> <url> <url> 1 Answer 1 ...

How do I use variables in single quoted strings?

How do I use variables in single quoted strings? I am just wondering how I can echo a variable inside single quotes (I am using single quotes as the string has quotation marks in it). echo 'test text "here_is_some_test_text_$counter" "output"' >> ${FILE} any help would be greatly appreciated 7 Answers 7 Variables are expanded in double quoted strings, but not in single quoted strings: $ name=World $ echo "Hello $name" Hello World $ echo 'Hello $name' Hello $name If you can simply switch quotes, do so. If you prefer sticking with single quotes to avoid the additional escaping, you can instead mix and match quotes in the same argument: $ echo 'single quoted. '"Double quoted. "'Single quoted again.' single quoted. Double quoted. Single quoted again. $ echo '"$name" has the value '"$name...

Extract IPs from multiples websites using bash and awk

Extract IPs from multiples websites using bash and awk I'm looking for the best way to get multiples websites IPs and output them as "domain.com:","1.1.1.1" in order to achieve this I was thinking on using nslookup (not sure if is the best option but I don't want to use ping) "domain.com:","1.1.1.1" nslookup Well I was trying something like: for domain in $(cat domains.txt) do nslookup $domain 8.8.8.8 | awk '/Address: ([[:digit:]]+.){3}/{gsub(/.$/,"",$1); printf ""%s","%s"n",$1,$NF}'; done With this, I'm get this output: "Address:","64.233.190.101" "Address:","64.233.190.138" "Address:","64.233.190.100" "Address:","64.233.190.139" "Address:","64.233.190.113" "Address:","64.233.190.102" "Address:","98.137.246.8" "Address:","98.138....