sh

How to automate creation of new XCode targets from Applescript/Automator/Shell Script

我们两清 提交于 2019-11-30 04:17:34
I am currently working on a way to automate the process of adding new targets to my XCode projects. One target has to be added to multiple XCode projects and each target in the different project needs the same source files to be added, same groups to store the source files in the XCode project, and the same build settings. Doing this manually can take a while and is very prone to human error, and I have to do this task fairly often. I have already written a script to generate new source files, copy them to system folders, edit source files with new information etc, but now I need to automate

can't source script in a current directory

本小妞迷上赌 提交于 2019-11-30 03:24:15
问题 So apparently, I can't source a script if that script is in the current directory. For example, # source some/dir/script.sh Ok works fine, but if I'm in the same dir as the script, it errors out: # cd some/dir # source script.sh -sh: source: script.sh: file not found What gives? Is the only way around this to change directory? I'm using bash v4.2.10 on Angstrom Linux if that's relevant. 回答1: Quoting the source man page: source filename [arguments] .... If filename does not contain a slash,

Get pid of current subshell

為{幸葍}努か 提交于 2019-11-30 02:59:00
I am trying to get the pid of a currently executing subshell - but $$ is only returning the parent pid: #!/usr/bin/sh x() { echo "I am a subshell x echo 1 and my pid is $$" } y() { echo "I am a subshell y echo 1 and my pid is $$" } echo "I am the parent shell and my pid is $$" x & echo "Just launched x and the pid is $! " y & echo "Just launched y and the pid is $! " wait Output I am the parent shell and my pid is 3107 Just launched x and the pid is 3108 I am a subshell x echo 1 and my pid is 3107 Just launched y and the pid is 3109 I am a subshell y echo 1 and my pid is 3107 As you can see

Adding users to sudoers through shell script

爷,独闯天下 提交于 2019-11-30 01:36:10
Is it possible to add users to the sudoers file through a shell script? I've been looking around, still can't find anything. wchargin You could simply echo (with elevated privileges, of course) directly to the /etc/sudoers file: sudo -i echo 'nickw444 ALL=(ALL:ALL) ALL' >> /etc/sudoers # ^^ # tab (note the tab character between the username and the first ALL ) Or, for a script: #!/bin/bash # Run me with superuser privileges echo 'nickw444 ALL=(ALL:ALL) ALL' >> /etc/sudoers Then save to somefile.sh , chmod a+rx it, and run sudo ./somefile.sh from a terminal window. To add multiple users, change

How to get /etc/profile to run automatically in Alpine / Docker

☆樱花仙子☆ 提交于 2019-11-30 00:09:25
How can I get /etc/profile to run automatically when starting an Alpine Docker container interactively? I have added some aliases to an aliases.sh file and placed it in /etc/profile.d , but when I start the container using docker run -it [my_container] sh , my aliases aren't active. I have to manually type . /etc/profile from the command line each time. Is there some other configuration necessary to get /etc/profile to run at login? I've also had problems with using a ~/.profile file. Any insight is appreciated! EDIT: Based on VonC's answer, I pulled and ran his example ruby container. Here is

Running full commands through remote ssh [duplicate]

可紊 提交于 2019-11-29 23:05:46
Possible Duplicate: how to use ssh to run shell script on a remote machine? I am trying to make a bash script that runs on my remote server's daily cron jobs to automatically login through ssh to another unix box, run a few commands and then leave. #!/bin/bash ssh machinehost.com -l admin -p 2222 "/usr/bin/find /share/Public/backups/set0 -mtime +14 | xargs rm -f; /usr/bin/find /share/Public/backups/set1 -mtime +4 | xargs rm -f; /usr/bin/find /share/Public/backups/set2 -mtime +3 | xargs rm -f; /usr/bin/find /share/Public/backups/set3 -mtime +21 | xargs rm -f; /usr/bin/find /share/Public/backups

Explanation of convertor of cidr to netmask in linux shell netmask2cdir and cdir2netmask [closed]

こ雲淡風輕ζ 提交于 2019-11-29 21:49:26
I found the following shell functions from this topic mask2cdr () { # Assumes there's no "255." after a non-255 byte in the mask local x=${1##*255.} set -- 0^^^128^192^224^240^248^252^254^ $(( (${#1} - ${#x})*2 )) ${x%%.*} x=${1%%$3*} echo $(( $2 + (${#x}/4) )) } cdr2mask () { # Number of args to shift, 255..255, first non-255 byte, zeroes set -- $(( 5 - ($1 / 8) )) 255 255 255 255 $(( (255 << (8 - ($1 % 8))) & 255 )) 0 0 0 [ $1 -gt 1 ] && shift $1 || shift echo ${1-0}.${2-0}.${3-0}.${4-0} } Could you explain in details how these functions convert cidr to netmask and the netmask to cidr?

envsubst: command not found on Mac OS X 10.8

[亡魂溺海] 提交于 2019-11-29 21:14:35
When I try to run a script that contains the envsubst command, I get this error. Looking online, this seems to be a standard bash command, so I am not sure what to install in order to get it to work. Edit: @cobberboy 's anwer is more correct. upvote him. brew install gettext brew link --force gettext Following is my old answer: envsubst is included in gettext package. Therefore you may compile it by your own, using standard build tools such as make or using homebrew . However, it seems to have little issue when installing gettext in MacOS. See following url for details: How to install gettext

echo >&2 “some text” what does it mean in shell scripting

强颜欢笑 提交于 2019-11-29 19:57:24
I have seen echo being used like this in many places: echo >&2 message text ... What does this mean? I understand 2>&1 , however, I am not sure how to interpret the usage above. Can anyone please explain? To quickly explain what the others missed: echo "hey" >&2 > redirect standard output (implicit 1> ) & what comes next is a file descriptor, not a file (only for right hand side of > ) 2 stderr file descriptor number Redirect stdout from echo command to stderr . (If you were to use echo "hey" >2 you would output hey to a file called 2 ) Michael Aaron Safyan The use of >&2 here is sending the

Capturing the PID of a background process started by a Makefile

社会主义新天地 提交于 2019-11-29 19:35:22
问题 I have a Makefile that starts a Django web server. I would like the server to be started in the background, with the PID saved to a file. My recipe looks like this: run: venv @"${PYTHON}" "${APP}/manage.py" runserver 80 Intuitively, to background the process and capture the PID, I'd have to do something like this: run: venv @"${PYTHON}" "${APP}/manage.py" runserver 80 & ; echo "$$!" > "${LOGDIR}/django.pid" This doesn't work, though. The sub-shell that 'make' uses (/bin/sh in my case) works