w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
crucible init.d bash script
For a semi-official answer, see How to start FishEye and Crucible at boot time on Linux.

Categories : Bash

Generating subnet CIDR blocks programmatically in CloudFormation templates (or adding integers together)
My solution for these kinds of issues was to use a legitimate programming language to compile a template into a CloudFormation JSON document. I used PHP 5.4, Twig and Symfony Console, but YMMV. Essentially, you do the math ahead of time in the programming language, then use that data as you write-out your JSON document.

Categories : Amazon

Why won't my CloudFormation script download a file?
Jonathon, I tried your template and the file downloaded successfully for me. You can check the cfn logs on the instance. They are in c:cfnlog. My cfn-init.log shows: 2013-07-19 21:30:18,269 [DEBUG] Parent directory c: est does not exist, creating 2013-07-19 21:30:18,269 [DEBUG] Writing content to c: estgoogle-logo.png 2013-07-19 21:30:18,269 [DEBUG] Retrieving contents from http://www.google.com/images/srpr/logo4w.png 2013-07-19 21:30:18,316 [DEBUG] No mode specified for c: estgoogle-logo.png 2013-07-19 21:30:18,316 [WARNING] Unsupported OS for setting owner/group: nt And my cfn-wire.log shows: 2013-07-19 21:30:18,269 [DEBUG] Request: GET http://www.google.com/images/srpr/logo4w.png [headers: {'Accept-Encoding': 'identity, deflate, compress, gzip', 'Accept': '*/*', 'User-Agent': 'pyth

Categories : Amazon

How to start init.d script on bootup in embedded linux. I dont have update-rc.d. Is there any other way to start init.d script on linux boot?
You can edit the /etc/inittab file. Also, there are 2 other alternatives to update-rc.d: Rcconf - Rcconf allows you to control which services are started when the system boots up or reboots. It displays a menu of all the services which could be started at boot. The ones that are configured to do so are marked and you can toggle individual services on and off.This tool configures system services in connection with system runlevels. It turns on/off services using the scripts in /etc/init.d/. File-rc - Alternative boot mechanism using a single configuration file This package provides an alternative mechanism to boot the system, to shut it down and to change runlevels. The /etc/rc?.d/* links will be converted into one single configuration file /etc/runlevel.conf inste

Categories : Linux

how to construct a string of physical subnet ids to create db subnet group on the fly in a cloudformation script?
I run into the same issue, after working with AWS support I understood that List of String does not mean what we initially thought. Also, if you want to place the DB inside a VPC you must not use AWS::RDS::DBSecurityGroup objects. Here is a full sample, it took me a while to get it working: "dbSubnetGroup" : { "Type" : "AWS::RDS::DBSubnetGroup", "Properties" : { "DBSubnetGroupDescription" : "Availability Zones for RDS DB", "SubnetIds" : [ { "Ref" : "subnetPrivate1" }, { "Ref" : "subnetPrivate2" } ] } }, "dbInstance" : { "Type" : "AWS::RDS::DBInstance", "Properties" : { "DBInstanceIdentifier" : { "Fn::Join" : [ "", [ { "Ref" : "AWS::St

Categories : Amazon

relation between init and bash terminal process
Nothing is shared between init and its terminal children, nor between the first terminal and its terminal child. This is because, although fork() will make both processes (father and child) to share some objects, exec() family functions completely replaces the current process image with a new process image. This means that all references to previous objects, such as shared file descriptors from the father, are forgotten.

Categories : Linux

Bash script to wait for gnome-terminal to finish before continuing script, only works for first instance of script
#!/bin/bash date bash -c "sleep 7" & bash -c "sleep 5" & wait date As you can see while running this script, both sleep commands will run in parallel, but main thread stalls, while they are running. Sat. Jule 27 01:11:49 2013 Sat. Jule 27 01:11:56 2013 Replace sleep 7 with expect launchneuron.exp and sleep 5 with expect launchmpj.exp and add your plot commands after calling "wait": echo "Simulation Complete" ...(your code to plot results)

Categories : Bash

Why does the child of an eval call from bash get orphaned once the parent bash script dies?
This is normal and expected. You sent a signal (presumably SIGTERM) to parent-script and it died, but no signal was sent to another-script. It keeps on running. This is different than what happens when the parent-script job is running interactively on a terminal and you type ^C (or ^Z). In that case, a SIGINT signal is automatically sent to the whole foreground process group. Since another-script is un the same process group as parent-script (by default), they both get the signal and they both die. If you want another-script to die automatically when its parent dies in any other context than when it's a job running in a terminal with job control, you have a few options. parent-script can trap the SIGTERM signal. In the signal handler, it kills its child, and then exits itself. This, o

Categories : Linux

BASH: how to define an array as environment variable before calling a bash script
Incredibility weird.... I have never seen that before. It looks like the array is not passed to the subshell. One way around this is to source the script instead of executing it: declare -a MYARR=( 1 2 ); . ./myscript.sh

Categories : Arrays

Pass a full bash script line to another bash function to execute
optout is a command like any other, and so must be preceded by any local modifications to the environment. The command that optout runs will inherit that environment. CC=${BUILD_TOOL_CC} optout ./configure ${ZLIB_CONFIGURE_OPT} --prefix=${CURR_DIR}/${INSTALL_DIR} By the way, this is just one of the problems you are likely to encounter with your optout function. You cannot run arbitrary command lines in that fashion, only a simple command followed by zero or more arguments (and I would expect there are some exceptions to even that restricted set, as well).

Categories : Linux

escaping bash 'test' keywork in a bash script
test is a Bash builtin command, not a keyword or reserved word. This means Bash will only interpret it if it is the first token in a command, like test blah In python manage.py test Bash will just pass it as a parameter to python (that is, it will execute python with two parameters, manage.py and test); you don't need to escape it. In general, Bash doesn't have reserved words in the sense of C-like languages. The only things you need to escape are whitespace (which Bash uses to separate params), and certain symbols including $(&|; which Bash uses for its variables and command separators.

Categories : Bash

'Globalize' Bash functions inside of a bash script
You can use this command in your startup.bash: source lib.bash the source command runs the file in the current shell environment, unlike using bash lib.bash (or . lib.bash) which creates a new, separate environment for that script (and only that script) and is why the function is not carried over. (source)

Categories : Linux

Can One Bash Script Launch Multiple Other Bash Scripts?
Run them in the background, just like you would in an interactive shell. command1 & command2 & command3 & wait # Wait for all background commands to finish The commands can be just about anything, not just other bash scripts.

Categories : Linux

Linux startup script instead init.d
The file /etc/rc.local is a good candidate for local jobs, and it avoids some of the complexity of using /etc/init.d/ and similar directories. Just add a line to /etc/rc.local to launch your job.

Categories : Linux

Manage sidekiq with init.d script using RVM
use wrappers: BUNDLER=/usr/local/rvm/wrappers/ruby-1.9.3-p385/bundle in case the bundler wrapper is not available generate it with: rvm wrapper ruby-1.9.3-p385 --no-links bundle # OR: rvm wrapper ruby-1.9.3-p385 --no-links --all you can use aliases to make it easier: rvm alias create my_app 1.9.3-p385 and then use it like this: BUNDLER=/usr/local/rvm/wrappers/my_app/bundle this way you will not have to change the script when application ruby changes - just update the alias, there is a good description/integration for this in rvm-capistrano => https://github.com/wayneeseguin/rvm-capistrano/#create-application-alias-and-wrappers

Categories : Ruby On Rails

How to run a command as a specific user in an init script?
I usually do it the way that you are doing it (i.e. sudo -u username command). But, there is also the 'djb' way to run a daemon with privileges of another user. See: http://thedjbway.b0llix.net/daemontools/uidgid.html

Categories : Linux

Starting Gitlab with init.d script (gentoo)
There are two problems here. Firstly, rvm is normally only loaded by the user's shell and that shell isn't being invoked here. Secondly, bundle won't be in the PATH either. To fix both problems, assuming this is a per-user rvm installation, try this... ... --exec /home/gitlab/.rvm/bin/rvm -- default do bundle exec ... As a side note, you shouldn't use unicorn_rails with Rails 3 applications. Just use plain unicorn instead.

Categories : Misc

How to get this init.d script to start at server restart?
You should tell us how exactly you are running the script from init.d But here is a dirty workaround: Change the line start) to start|'') This will make it start if there are no parameters passed.

Categories : Linux

how to create a script from a perl script which will use bash features to copy a directory structure
First, I see that you want to make a copy-script - because if you only need to copy files, you can use: system("cp -r /sourcepath /targetpath"); Second, if you need to copy subfolders, you can use -r switch, can't you?

Categories : Perl

bash shell script error works on command line, not in script
Variables are supposed to contain data, and bash treats them as data. This means that shell meta-characters like quotes are also treated as data. See this article for a complete discussion on the topic. The short answer is to use arrays instead: ASCIIDOC_OPTS=( --asciidoc-opts='-a lang=en -v -b docbook -d book' ) DBLATEX_OPTS=( --dblatex-opts='-V -T db2latex' ) cmd=(a2x -v -f pdf -L "${ASCIIDOC_OPTS[@]}" "${DBLATEX_OPTS[@]}" "$1".asciidoc) # Print command in pastable format: printf '%q ' "${cmd[@]}" printf ' ' # Execute it "${cmd[@]}" Make sure not to use eval: eval "$cmd" #noooo This will appear to work with your code as you posted it, but has caveats and security problems.

Categories : Bash

Create bash script with menu of choices that come from the output of another script
This might work for you: #!/bin/bash # Set the prompt for the select command PS3="Type a number or 'q' to quit: " # Create a list of customer names and numbers (fill gaps with underscores) keys=$(/usr/local/bin/info $1 | sed 's/ /_/g') # Show a menu and ask for input. select key in $keys; do if [ -n "$key" ]; then /usr/local/bin/extrainfo $(sed 's/.*_11111/11111/' <<<"$key") fi break done

Categories : Bash

How to pass output from remote script to local script in bash
On your local script, in your ssh line, you can redirect some of the outputs to a file with tee: ssh ... | tee -a output.log If you want to filter which one goes to the output.log file, you can use process substitution: ssh .... | tee >(grep "Some things you want to filter." >> output.log) Besides grep you can use other commands as well like awk.

Categories : Bash

dump files from bash script in different directory from where python script ran it
You should change directory within the same command: cmd = "/path/to/executable/executable" outputdir = "/path/to/output/" subprocess.call("cd {} && {}".format(outputdir, cmd), shell=True)

Categories : Python

user-data (cloud-init) script not executing on EC2
Cloud-init does not accept plain bash scripts, just like that. It's a beast that eats YAML file that defines your instance (packages, ssh keys and other stuff). Using MIME you can also send arbitrary shell scripts, but you have to MIME-encode them. $ cat my-boothook.txt #!/bin/sh echo "Hello World!" echo "This will run as soon as possible in the boot sequence" $ cat my-user-script.txt #!/usr/bin/perl print "This is a user script (rc.local) " $ cat my-include.txt # these urls will be read pulled in if they were part of user-data # comments are allowed. The format is one url per line http://www.ubuntu.com/robots.txt http://www.w3schools.com/html/lastpage.htm $ cat my-upstart-job.txt description "a test upstart job" start on stopped rc RUNLEVEL=[2345] console output task script echo "==

Categories : Linux

Program can't open file when started from init.d script
Since you're using relative paths to open the file here is what is most likely the issue. The working directory when you launch the application from your script is the directory in which the script is found and not the directory in which the application is. And so when you use relative paths to find the file they're relative to the directory of the script which is why it can't find them when you execute from script but can when you execute directly from command line. You can test this theory by moving the script to the application's directory and trying to run it. If it works from script while the script and application are in the same directory then I'm right. nothing can be sure since we don't have your code.

Categories : C++

BASH: How To Create a Setup Script to build another script
This answer, a work in progress; Your code while [ "$index" -lt "$elements" ] do ????????? echo "Your Directory is ~/$root/${gitdir[0]}/${gitdir[1]}/${colours[2]}" done becomes fullPath="/${root}/" index=1 while [ "$index" -lt "$elements" ] ; do # append values from $gitdir until you are done fullPath="${fullPath}/${gitdir[$index]}" (( index++ )) done # not sure how colours got introduced to this but same idea fullPath="${fullPath}/${colours[2]}" echo "Your Directory is ~/${fullPath}" use of (( index++ )) implies using a version of bash, ksh, zsh (maybe others) that support arithmetic evaluations. That said, it's not clear what your input into gitdir[@] will be and why you need to "count" the levels. Why not just accept user input as arguments, document the o

Categories : Arrays

how can i pass a variable from my php script and send it to my bash script
Try using shell_exec in your php script to execute your shell script and pass your variable, like so: $cmd="perl -pi -e 's/ : /:/g' /opt/lampp/htdocs/" . escapeshellarg($variable); $r=shell_exec($cmd); escapeshellarg is used to escape any potentially dangerous characters in $variable, to prevent a command line injection attack.

Categories : PHP

Run PBS script and post-process output within bash script
I don't believe PBSPro supports this, but TORQUE (another PBS derivative) has a -x option that you might be interested in. You can submit a job like this: qsub -I -x <executable> This would run your job interactively and run the executable, with all of the output directed to your terminal, and the job will execute as soon as that executable terminates. You could then begin post-processing at that point. PBSPro may have similar functionality, but what I've described here is for TORQUE.

Categories : Bash

Bash: increment a variable from a script every time when I run that script
A script is run in a subshell, which means its variables are forgotten once the script ends and are not propagated to the parent shell which called it. To run a command list in the current shell, you could either source the script, or write a function. In such a script, plain (( n++ )) would work - but only when called from the same shell. If the script should work from different shells, or even after switching the machine off and on again, saving the value in a file is the simplest and best option. It might be easier, though, to store the variable value in a different file, not the script itself: [[ -f saved_value ]] || echo 0 > saved_value n=$(< saved_value) echo $(( n + 1 )) > saved_value Changing the script when it runs might have strange consequences, especially when yo

Categories : Bash

howto enable android tether on boot with init.d script
This answer may help you better, although for me it didn't work, probably because of some missing parameters. If you succeeded please post the solution.

Categories : Android

Where to find logs for a cloud-init user-data script?
You could create a cloud-config file (with "#cloud-config" at the top) for your userdata, use runcmd to call the script, and then enable output logging like this: output: {all: '| tee -a /var/log/cloud-init-output.log'}

Categories : Misc

After I deleted a directory, it always prompts "shell-init error retrieving current directory getcwd solve" when log on bash
When opening a new shell or xterm, it's started in the working directory of the process that started it. If you e.g. cd /proc && xterm, the new terminal will place you in /proc. Whatever's starting your terminal had positioned itself in /home/desktop/zeno, and now all the terminals are trying to start there. If you make that process change directory (by rebooting, for example), the terminals will start in a directory that exists and you will no longer get this error.

Categories : Linux

Have an init script on Android that starts a browser full screen on a defined URL?
If by init script you mean something that launches a browser at startup, than your only solution is to create a custom launcher, that does nothing but starts the browser full screen. Intent for browser launch. Custom launcher. You have to set it manually, but after that it'll become the default launcher. By the way, I would suggest Android sticky thing, as you said it's plug and play, and it has everything out of the box: storage, WiFi, Bluetooth, HDMI cable. If you buy a Raspberry even if software installation is easy, you'll have to add a lot of stuff before you can use it, almost doubles the price.

Categories : Android

need to call a php script from bash script through eval
There are still some parts of your script that I don't understand, or not sure it does really work, but about your question, I think your callback could only work if you place it on a function like: function mycallback { php /srv/www/scripts/mage/install-invoke-app.php } And call your install_repolist function as install_repolist $gitRepos 0 mycallback That should make your php command call with the file argument work but there is one thing: I don't think values of gitRepos could actually be passed like that. Most parts of your code has variables that actually needed to be quoted around double quotes "". One problem with it is that your php command would just end up in the final place where it is executed as one single argument php and no longer with the file due to word splitti

Categories : PHP

How to source a csh script from inside a bash script
WARNING : don't put the following script in your .bashrc, it will reload bash and so reload .bashrc again and again (stopable with C-c anyway) Use preferable this script in your kit/CDS stuff startup script. (cadence presumably) WARNING 2 : if anything in your file2source fails, the whole 'trick' stops. Call this script : cshWrapper.csh #! /bin/csh # to launch using # exec cshWrapper.csh file2source.sh source $1 exec $SHELL -i and launch it using exec ./cshWrapper.csh file2source.sh it will : launch csh, source your file and came back to the same parrent bash shell Example : $> ps PID TTY TIME CMD 7065 pts/0 00:00:02 bash $>exec ./cshWrapper.csh toggle.csh file sourced 1 $> echo $$ 7065 where in my case i use the file toggle.csh #! /bin/csh # source

Categories : Misc

How to display Nested Attributes in Underscore Java script Templates
You need to pass nutrition.toJSON() or _.clone(nutrition.attributes) to the template. Otherwise you get the model object, not the raw data. To get every sub-attributes, you could to recurse through the nested attributes to expose them directly. Otherwise, you can access them directly via the attributes object. e.g. cholesterol.attributes.<attr>

Categories : Backbone Js

using require and backbone to load templates via html file and not script tag
Install the text plugin which is available at https://github.com/requirejs/text Then proceed to define the plugin in here: require.config({ paths: { text: '{{directory where you put text.js}}', } }); Since we are at this topic, requirejs-tpl-plugin is a better option https://github.com/jfparadis/requirejs-tpl

Categories : Javascript

Executing bash script from php script
I would have a directory somewhere called scripts under the WWW folder so that it's not reachable from the web but is reachable by PHP. e.g. /var/www/scripts/testscript Make sure the user/group for your testscript is the same as your webfiles. For instance if your client.php is owned by apache:apache, change the bash script to the same user/group using chown. You can find out what your client.php and web files are owned by doing ls -al. Then run <?php $message=shell_exec("/var/www/scripts/testscript 2>&1"); print_r($message); ?> EDIT: If you really want to run a file as root from a webserver you can try this binary wrapper below. Check out this solution for the same thing you want to do. Execute root commands via PHP

Categories : PHP

Bash: Why does parent script not terminate on SIGINT when child script traps SIGINT?
New answer: This question is far more interesting than I originally suspected. The answer is essentially given here: What happens to a SIGINT (^C) when sent to a perl script containing children? Here's the relevant tidbit. I realize you're not using Perl, but I assume Bash is using C's convention. Perl’s builtin system function works just like the C system(3) function from the standard C library as far as signals are concerned. If you are using Perl’s version of system() or pipe open or backticks, then the parent — the one calling system rather than the one called by it — will IGNORE any SIGINT and SIGQUIT while the children are running. This explanation is the best I've seen about the various choices that can be made. It also says that Bash does the WCE appr

Categories : Linux

Syntax highlight javascript templates within