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

RoR: Shell/System commands with write property not working in production mode?
On your server you should have a user different from root for security reasons. Than this user should be added to sudoers list: http://askubuntu.com/questions/7477/how-can-i-add-a-new-user-as-sudoer-using-the-command-line now, depending where you want to create this folder, if it's in your app folder where your user has permissions to read/write, (search chmod 755 and chown to set the owner of the folder, better use chown -R to apply this to all subfolders), after this you'll be able to create that folder with: System("mkdir test") but only in folders where your user has access to read/write. If you want to create the test folder in some other path where you need to use sudo you'll have to run: System("sudo mkdir test") normally this is running in a background and you won't be the

Categories : Ruby On Rails

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

How to fix TPM in Redhat Linux? RedHat Linux hang on first time to boot after installing
After all my search I found out that in Redhat 6 there is a problem tboot and best way to fix it is to remove tboot package (it is located in System Base>Base>tboot.6) For more info about tboot you can check these links: enter link description here

Categories : Linux

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

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

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

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

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

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

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

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

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

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 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

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

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

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

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

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

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

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

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++

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

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

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

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

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

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

unable to run commands in shell script after su mqm command,but able to run in putty?Pleae let me know how to execute.?
putty is interactive command line. Try the below. bash variables can be used. #!/bin/bash su - mqm -c "echo 'DISPLAY QLOCAL (<QUEUENAME>) CURDEPTH'|runmqsc QUEUEMANAGER"

Categories : Bash

Unable to persist the shell environment with rvm set, for executing further commands through a ruby script
Each Ruby shellout happens in its own, discrete shell. You could maybe do something like use popen to spawn a bash shell, then pipe your commands to it, but all you're doing then is running a bash script. Your better bet would be to create a full bash script, then to execute it with rvm do to run it in the context of your chosen RVM environment. You can invoke this from ruby, by executing something like rvm do 2.0.0 bundle install && rake or whatever, but at the end of the day, you're talking about running shell commands, so you should be doing it with shell syntax.

Categories : Ruby

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

How to open a bash/ssh session in shell script and run commands in the remote session?
Take a look into expect, which "talks" to interactive programs with the help of a user provided script. Usage expect ./interact or making interact executable (chmod a+x interact): ./interact where interact is the following script: #!/usr/bin/expect spawn ./a.out send -- "yes " expect "3292 " send -- "no " This is just a simple example, the man page is full of in depth explanations and there are also example scripts which come with the installation. References http://linuxaria.com/howto/2-practical-examples-of-expect-on-the-linux-cli?lang=en Best way to interact with a service for exploitation purpose

Categories : Linux

Change php script with variables from working in http to working in shell
have a look on: How to pass GET variables to php file with Shell? which already answered the same question :).

Categories : PHP

Some Process.Start commands not working
Summarizing what I put in the comments - you're seeing the issue because you're running in a 32-bit process that is then subject to File System Redirection - your attempts to access the System directory get redirected to (by default) C:WindowsSysWOW64. This directory doesn't contain an msconfig.exe. Visual Studio 2012, introduced a AnyCPU Prefer 32-bit option, and that is selected by default. Best advice would be to switch your build platform to 64-bit, or uncheck Prefer 32-bit.

Categories : C#

commands not working after editing bashrc file
You needed to preserve the earlier PATH. Instead of saying: export PATH=$CUDA_INSTALL_PATH/bin say: export PATH=${CUDA_INSTALL_PATH}/bin:${PATH}

Categories : Bash

String commands for Arduino sketch kind of working but not really
Your code should not compile as pasted here. The checkForCorrectCommand function does not have a return value for both the match and unmatch. Your code shows you intend to empty the inputString buffer for both the match and non matched case. If the string match is not true, you want to leave the input buffer unchanged so that the following test cases can run. bool checkForCorrectCommand(String cmd) { if(inputString == cmd) { // for match case, the string is consumed from the buffer inputString = ""; stringComplete = false; return true; } else { // for the non-match case, leave the buffer for further Rx or further tests return false; }

Categories : C

Making a user in Samba - Debian 6 32bit - No commands working?
Solution: Setup Apt-get upgrade sudo apt-get install samba smbfs sudo mkdir –m 0777 /pathofdrive Editing the samba config sudo vi /etc/samba/smb.conf Copy this: # Global parameters [global] workgroup = HOME netbios name = SAMBA server string = Samba Server %v map to guest = Bad User log file = /var/log/samba/log.%m max log size = 50 socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192 preferred master = No local master = No dns proxy = No security = User # Share [Data] path = /disk2/data valid users = joel read only = No create mask = 0777 directory mask = 0777 Adding a user: # useradd -c "Joel Nahrgang" joel # smbpasswd -a joel New SMB password: secret Reenter SMB password: secret Added user joel Restarting Samba:

Categories : Linux



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