w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
what's the difference between "hadoop fs" shell commands and "hdfs dfs" shell commands?
fs refers to any file system, it could be local or HDFS but dfs refers to only HDFS file system. So if you need to perform access/transfer data between different filesystem, fs is the way to go.

Categories : Hadoop

Run commands through Shell Scripts in linux
Use && between commands: it will execute the next command only if the previous command execution is a success. The || does the inverse => echo "error" will be displayed if one of the both cp fails. #!/bin/sh cp ~/SURV/plugins/iConomy/accounts.mini ~/backups/ && cp ~/SURV/plugins/CoreProtect/database.db ~/backups/ && echo "Backups creados con éxito!" || echo "error" You can also add -v option to the cp command for more visibility. In order to make your script executable you have to do: chmod +x backup.sh

Categories : Linux

Can I invoke linux shell commands in a R session?
See here Use system (or shell) as agstudy's comment says e.g. system("pwd")

Categories : R

When does I/O redirection occur relative to the execution of commands in the Linux shell?
You are correct; the I/O redirection takes place before the find command is executed, so the file file2.txt already exists (but is empty) when the find command is running. Therefore, the output of the find command will include file2.txt. It makes sense if you think about it. The redirection has to be done before find executes. You can't have it writing to the terminal first and then going to the file, even if there was a mechanism that allowed that.

Categories : Linux

linux: what is the difference between these two symbolic link commands
A symbolic link is implemented as a file containing the name of the target. There is a minor difference, as you've seen: one of the symlinks has a trailing /, and the other doesn't. You can see the difference in the output of ls -l; on a lower level, this shows up as a difference in the path returned by the readlink() system call. But there should be no functional difference between them -- as long as the target is a directory. Either can be used to access the linked directory. For a target that's not a directory, this: ln -s /etc/motd good_link ln -s /etc/motd/ bad_link will result in good_link being a valid way to access /etc/motd, and bad_link resulting in a not a directory error.

Categories : Linux

Is a difference in the implementation of boost::asio between Unix(AIX, HP-UX) and Linux(RedHat, Ubuntu)?
The platform specific implementation notes describes the supported platforms and how the event demultiplexing is implemented. Newer Linux kernels will use epoll(4) while older versions use select(2). AIX and HP-UX both use select(2). kqueue(2) is used on BSD systems, including Mac OS X and iOS. It is very similar to epoll on Linux. Generally speaking, epoll will perform better than select. When using select, it performs a linear search over the list of n descriptors, this is O(n). Using epoll has the concept of an epoll_event structure when adding descriptors to the epoll descriptor. This means modifying the list of events to wait for is somewhat expensive, but waiting for these events is very fast at O(1).

Categories : Misc

Use shell script wrapper to enter commands into a new shell
If the sequence of commands is fixed (does not change from run to run), you might be able to use: #!/bin/sh Dbm2 <<EOF table THE_TABLE ...other commands... EOF ls # Just to demonstrate that the shell continues The <<EOF notation is a here-doc. The lines up to the line containing EOF are the input to the command Dbm2. If the content of the commands needs to vary, you may be able to pipe the input to Dbm2. In your script, if you manually enter commands to Dbm2 and then quit, your original shell script should continue. The table THE_TABLE line would be treated as another shell command and would, most likely, fail.

Categories : Shell

Ubuntu/Python- How to call ubuntu commands and 3rd party applications through Python
Take a look at os.path for directory navigation. To execute a shell command use os.system. The example you posted could go something along the lines of: os.chdir(os.path.expanduser('~/Documents/XDF_Thumbnails_Sci')) for file in os.listdir('.'): if os.path.splitext(file)[1] == ".feedme": os.system("~/galfit %s" % file)

Categories : Python

How to search for previous commands in ubuntu?
In your terminal, do the following: Note: I have done the ff on Mac. In Ubuntu, you can use bashrc instead of bash_profile. echo 'export HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bash_profile If the HISTTIMEFORMAT is set, the time stamp information associated with each history entry is written to the history file, marked with the history comment character. then, execute: history you can now see your command history like this: 398 05/09/13 08:45:15 ifconfig 399 05/09/13 08:45:15 ./adb kill-server 400 05/09/13 08:45:15 ./adb start-server 401 05/09/13 08:45:15 ./adb devices

Categories : Ubuntu

shell_exec does not run some shell commands
What output do you expect from that script? I shell_exec() will probably only output STDOUT, so if there's errors you will need to redirect them from STDERR like this: <command> 2>&1 I'm guessing here, but try it with just a simple echo statement in the shell script. See if that works.

Categories : PHP

shell executing number of commands
Probably, Ruby execution is slower than shell script, so expanding the sequence into three commands within shell is faster than doing it in Ruby. But the speed difference is probably small. And what matters more is whether each of the three commands have a logical significance within the Ruby code. If they are to be considered one chunk that is never separated within the level of logic in the Ruby code, then it makes more sense to connect them in shell. If each command does correspond to some logical concept in the Ruby code, then it makes more sense to separate them. Benchmark t = Time.now 100.times do system("echo foo; ls; echo bar ") end t1 = Time.now - t t = Time.now 100.times do system("echo foo ") system("ls ") system("echo bar ") end t2 = Time.now - t puts "Together: #{

Categories : Ruby

Execute shell commands with sudo via PHP
You have at least 4 options: Add the apache user to the sudoers file (and restrict it to run the one command!) In this case some security hole in your php-apps may run the script too (if they can include the calling php for example - or even bypass the restriction to your ip by using another url that also calls the script, mod_rewrite) Flag the script with the s bit Dangerous, don't do it. Run another web server that only binds to a local interface and is not accessible from outside This is my prefered solution, since the link calling the php is accessible by links from your main webserver and the security can be handled seperately. You can even create a new user for this server. Some simple server does the job, there are server modules for python and perl for example. It is not eve

Categories : PHP

Sending SSH shell commands with Apache SSHD
If you want a fully customized and controlled shell, then you can write your own implementation for org.apache.sshd.server.Command class and inside run() method, call the java.lang.Process to execute your own shell/DOS scripts and return results to the calling program via input and output streams of Command class. If the calling programs can execute normal shell commands like dir / mkdir / touch etc, then you can use org.apache.sshd.server.shell.InvertedShell class. There is a test class InvertedShellWrapperTest.java in the Apache SSHD package to give you a head start.

Categories : Java

Vim: blank screen on subsequent shell commands
If you mean that when the previous external command output is still visible, and Vim shows the "Press ENTER or type command to continue" prompt, :! will indeed clear the output. That is because Vim's command line (which you enter with :) is always at the bottom of the screen. There's no way around this. To help you with your problem, many people will recommend using a terminal multiplexer like screen or tmux, and use a split of Vim and a separate shell in two windows. You can then use the multiplexer's commands to move to / from Vim and resize the corresponding windows based on your needs. Without that, using just Vim, a workaround would be to capture the command output in a scratch buffer: :new | 0read !ls is the basic command; there are more elaborate implementations in plugins or o

Categories : Vim

Redirect output of shell commands to file
Why don't you use the shell function? Here is an example of how to redirect the output: Option Explicit Private Sub Form_Load() ExecCmd "dir >c:log.txt 2>&1" End Sub Private Sub ExecCmd(cmdline As String) Shell "cmd /c " & cmdline, vbHide End Sub

Categories : Shell

shell script containing ldapmodify - hardcoding commands
Use a "here" document: ldapmodify .. <<! dn: dc=example,dc=com changetype: modify replace: description - add: description description: The new description ! For example.

Categories : Linux

How to run shell commands in parallel without background processes?
First, if you want processes to be executed in parallel, they have to be background jobs. What do have you against using &? Second, you can use taskset to bind a process to a CPU core, or a set of cores. For example: taskset -c 0 cmd1 & taskset -c 1 cmd2 & taskset -c 2 cmd3 & taskset -c 3 cmd4 & This might not be a good idea though; if one process is idle for long periods of time the other 3 cannot use the core it's assigned to.

Categories : Linux

How to continue executing the next other commands after using "kill" in shell?
I would say $pid also contains the pid of your script. You can filter it out: script_pid=$$ pid=$(ps -ef | grep temp_tool | grep -Ev "grep|$script_pid" | awk '{print $2}') Though if you want the pids of the command temp_tool I would suggest this: ps -C temp_tool -o pid Instead of the ps -ef | grep ...

Categories : Linux

Shell - Pipe to multiple commands in a file
When you execute tee >(some_command) bash creates a subshell to run some_command. The subshell's stdin is assigned to the reading half of a pipe. bash leaves the name of this pipe on the command line, so that tee will pump its input into the pipe. The subshell's stdout and stderr are left unchanged, so they are still the same as tee's. So, when you execute tee >(some_command) | some_other_command Now, bash first creates a process to run tee, and assigns its stdout to the writing half of a pipe, and another process to run some_other_command, with its stdin assigned to the reading half of the same pipe. Then it creates another process to run some_command, as above, assigning its stdin to the reading half of another pipe, and leaving its stdout and stderr unchanged. However, stdo

Categories : Bash

Using values of variables in on-the-spot shell commands (using ``)
Instead of: num=`cut -f1 $line` You can do: num=$(echo "$line" | cut -f1) OR else using awk: num=$(awk '{print $1}' <<< $line) OR using pure BASH: num=${line%% *} Your command cut -f1 $line will try to cut first column from a file named as $line.

Categories : Bash

Can I use & > in a groovy script executing shell commands?
Yes, you have to invoke the shell to background a task like that. A pure groovy solution would be to run the process with consumeProcessOutputStream: new File("/someDir/something/${NAME}/logs/stop.log").newOutputStream { log -> "/someDir/myScripts/stop.sh $NAME".execute().consumeProcessOutputStream(log) }

Categories : Shell

What is happening internally when we called any shell commands
You can take a look yourself at what happens by using the strace utility. Run it with: strace sh -c 'ls -l | grep -r "string"' This will run a shell that in turn will run your command, and at the end strace will print out what's happening behind the scenes in terms of system calls.

Categories : C

Run the shell commands in Perl using system() function in Windows
You can run the system() command but there are caveats. A nice description is contained in Using system or exec safely on Windows. This article resulted in the Win32::ShellQuote module.

Categories : Windows

Using Shell to Check Whether a File Exists, and only if it does, Execute a Set of Commands
The confirm command has what you're looking for. capture confirm file "file.txt" if !_rc { # if the file exists, confirm will return error code 0 insheet using "file.txt" } Alternatively, you could put a capture before the insheet command, which will catch the syntax error. Check the [P] manual for more on capture and confirm.

Categories : Shell

Chain multiple awk commands and shell scripts in sequence
One of the improvements would be: awk 'BEGIN {FS="[<|>]"} /(elementname).*$/{matchingstring=$0} { printf "%s ", matchingstring}' input.xml > tmp.xml Can be replaced with : awk '/(elementname).*$/' input.xml > tmp.xml And also this below: awk 'BEGIN { FS="[<|>]"} NR==1{ print "<?xml version="1.0" encoding="UTF-8"?>" print "<listofelements>" }; { printf "%s ", $0 } END { print "</listifelements>";}' tmp2.xml > final.xml Can be changed to : awk 'BEGIN { print "<?xml version="1.0" encoding="UTF-8"?>"; print "<listofelements>"} END {print "</listifelements>";}1' tmp2.xml > final.xml

Categories : Shell

Executing shell commands with NSTask - Objective-C Cocoa
You could do something like: NSTask *task = [[NSTask alloc] init]; [task setLaunchPath:@"/bin/bash"]; [task setArguments:@[ @"-c", @"/usr/bin/killall Dock" ]]; [task launch]; Exactly what launch path and arguments you provide are dictated by the command you want to run and its parameters.

Categories : Objective C

Running shell commands in GVim without echoing the Vim command
You could try the :redir command: *:redi* *:redir* :redi[r][!] > {file} Redirect messages to file {file}. The messages which are the output of commands are written to that file, until redirection ends. The messages are also still shown on the screen. When [!] is included, an : : To stop the messages and commands from being echoed to the screen, put the commands in a function and call it with ":silent call Function()". An alternative is to use the 'verbosefile' option, this can be used in combination with ":redir". I haven't tested, but

Categories : Shell

Preventing Embedded Python from Running Shell Commands?
One option is to remove all the modules that allow running arbitrary shell commands, i.e.: subprocess.py*, os.py*... and include only the modules that the end users are allowed to have immediate access to.

Categories : C++

why there is difference between the two commands
uniq replaces multiple consecutive occurrences of a line with one line; if they're not consecutive, they're not replaced. For example, consider input: word word other word word which uniq will turn into: word other word Now, when you sort first, then the original input becomes: other word word word word and then uniq, which now has all words consecutively, will output: other word

Categories : Sorting

Difference between ubuntu and ARM Ubuntu
ARM Ubuntu according http://www.ubuntu.com/download/arm is for ARM-based systems only. It supports Calxeda ECX-1000 and Marvell Armadaxp (12.04 LTS only) production boards. Ubuntu update will not happen automatically. It checks if there is new updates automatically but never will update without yours permission. Security updates can be enabled to be updated automatically. For this you need to install unattended-upgrades: sudo apt-get install unattended-upgrades sudo dpkg-reconfigure unattended-upgrades If you want to have home server - install Ubuntu Server 12.04 LTS. It's reliable and the most important free. It will do all your detailed operations like file sharing and more.

Categories : Ubuntu

Using python to substitute awk for Linux commands
You probably want to look at the datetime.datetime.strftime() function for that particular task. However, for the more general task of printing out certain fields, you'd use .split() and list slicing: date_string = "Mon Jun 24 01:30:08 EDT 2013" fields = date_string.split() print ' '.join(fields[1:5]) # Prints "June 24 01:30:08 EDT"

Categories : Python

I have to find time taken to register,run vm by euca commands using shell script
You can try the following one-liner to obtain the time taken by an instance to change it's state from pending to running, INS=$( euca-run-instances -k sshlogin -t m1.xlarge emi-F51D3A55 | grep INSTA | cut -f 2 ); time while(true); do if [ $( euca-describe-instances $INS | grep INSTANCE | cut -f 6 ) = "pending" ]; then euca-describe-instances $INS; else break; fi; done This should be reusable for other two as well.

Categories : Shell

How to run two commands in one line in shell script in ggsci command interpreter
Is there some reason you need to this on one line? A here document works fine for me ggs> ggsci <<HERE > DBLOGIN USERID abc, PASSWORD 123 > INFO ALL > HERE Oracle GoldenGate Command Interpreter for Oracle Version 11.2.1.0.6_02 16874194 OGGCORE_11.2.1.0.7_PLATFORMS_130530.0600.1_FBO Solaris, sparc, 64bit (optimized), Oracle 11g on Jun 5 2013 01:15:20 Copyright (C) 1995, 2013, Oracle and/or its affiliates. All rights reserved. GGSCI (foo01) 1> Successfully logged into database. GGSCI (foo01) 2> Program Status Group Lag at Chkpt Time Since Chkpt MANAGER RUNNING REPLICAT ABENDED PERF1REP 00:00:00 01:54:59 GGSCI (foo01) 3> ggs>

Categories : Oracle

Interpretation of the result of "cat /proc/bus/input/devices" and adb shell commands
The 1 "in-between /dev/input/event3/ and 116" stands for EV_KEY event type constant: EV_KEY: Used to describe state changes of keyboards, buttons, or other key-like devices. You could have found that on your own if you had run getevent -l /dev/input/event3/ and pressed the power key. Also to find out the power key input device name I would recommend parsing output of getevent -pl instead of contents of /proc/bus/input/devices. The device you are looking for has KEY_POWER listed in the events section: add device X: /dev/input/eventX name: "xxxxxxxxxx" events: KEY (0001): KEY_POWER And the proper long power key press sequence (as in press and hold for 1 second and then release) would be: sendevent /dev/input/eventX 1 116 1 sendevent /dev/input/eventX 0 0 0 sl

Categories : Android

MySQL commands running in shell script possess an error
edit your users ~/.my.cnf file and add [mysql] user=root password=7layer Secure the file: chmod 600 ~/.my.cnf then you might need to restart mysqld (/etc/init.d/mysqld restart), but are able to use : mysql <<EOF use $db; mysqld_safe --skip-grant-tables ###your sql queries### exit; EOF without a password update: This is not bound to your single script, it's bound to the user. If that's critical, setup a new user for the script that may access mysql without entering a password from command line. update: As you can see in your question, Shutting down MySQL.. your MySQL server is not running. Take a look into the logs why it's aborting. One of these should contain more information: /var/log/mysql.err /var/log/mysql.log /var/log/mysql/mysql.log /var/log/mysql/mysql.err

Categories : Mysql

How can i use exec() family system calls to implement the shell commands cp and rm ???
Here's are examples. The exec functions with l in their name take the list of arguments as their own arguments. The p suffix means that the command should be found using $PATH, so you can just supply the command name. execlp("cp", "cp", "sourcefile", "destfile", (char *)0); The variants with v take the argument in a single array argument ("v" stands for vector). In this case, I didn't use the e suffix, so I gave the full path to the program. char *args[] = {"rm", "file1", "file2", 0); execv("/bin/rm", args); In both cases, the first argument is also the name of the program, since this will become argv[0] in the new process. And the end of arguments is signified with a null pointer. You should provide the typecast explicitly when using the l variants, since varargs functions don't do

Categories : Linux

Difference between git reset commands
HEAD^ and HEAD~1 refer to the same commit. ^ refers to the first parent of the commit. ~n refers to the n:th ancestor. So ^^ (parent-of-parent) is equivalent to ~2. The main subtlety I can think of is if there is several parents to the current commit (i.e. it is a merge commit). In that case both HEAD^ and HEAD^2 are valid and refer to different commits. HEAD~1 refers to HEAD^ but not HEAD^2 The gitrevisions man page has lots of details and examples.

Categories : GIT

PHP Exec execute two commands at the same time in linux
If you put the & symbol at the end of the first command, it will run that command in the background (asynchronously) so that your PHP script will continue to the next line, where you can fire off the next command.

Categories : PHP

Calculate the average of several "time" commands in Linux
Like the commenter above mentioned, it sounds like you may want to use a loop to run your program multiple times, to get more data points. You can use the time command with the -o option to output the results of the time command to a text file, like so: time -o output.txt myprog

Categories : Linux

osx: launching a shell script containing gnu coreutils commands, works via terminal, not via applescript
Set $PATH in the shell script to include the path to the utilities: #!/bin/bash PATH=/opt/local/bin:/opt/local/sbin:$PATH path_to_open=$(...) && open "${path_to_open}"

Categories : Osx



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.