w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
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

Sort File using Shell Command
kent$ sort -k4nr file (6740, 7393, -653, 1.0969) Gates (7490, 7346, 144, 0.9808) Eliz (5044, 3913, 1131, 0.7758) Ian (6841, 3917, 2924, 0.5726) Frank (8365, 3634, 4731, 0.4344) Daniel (27231, 7105, 20126, 0.2609) Chad (4760, 699, 4061, 0.1468) Jack (5084, 500, 4584, 0.0983) Harry (51135, 2881, 48254, 0.0563) Brandon (71149, 3079, 68070, 0.0433) Alex

Categories : Bash

java shell command to sort csv file
Instead of handling the output in Java, you can use the -o or --output=FILE flag of the sort command and pass a filename for the output. If you pass the same filename as the input, it will be overwritten.

Categories : Java

Run shell command and send output to file?
Instead of running an entire shell process as root, which is arguably unsafe, you can run the copy as root: (with bash): sudo cp <(echo "$username") /etc/openvpn/auth.txt (should work with any shell): echo "$username" | sudo dd of=/etc/openvpn/auth.txt

Categories : PHP

Shell command to iterate through every line of a text file
ack works on whole files, line-by-line. For this, just do: ack "$line" ~/temp/imageFileNames.txt And it should print out all lines that contain whatever you put for "$line". Check the docs for a better usage description than I can give: http://linux.die.net/man/1/ack

Categories : Shell

How to Create zip file in PHP using shell command on linux server
The syntax is incorrect. Try zip foo abc.doc xyz.doc or zip -r foo abc.dox xyz.doc depending upon whether you intend to replace the existing archive or not. See man zip for more.

Categories : PHP

Shell command works in shell but not in shell script
You are using single quotes in this command: filelist=$(grep '$incstring' -rl --include=*.{h,cpp} pathToFiles) Single quotes inhibit variable expansion. That is, you're looking for the literal string $incstring rather than the contents of that variable. This command, as shown here, would not have worked on the command line either. From the bash(1) man page: Enclosing characters in single quotes preserves the literal value of each character within the quotes. A single quote may not occur between single quotes, even when preceded by a backslash. Replace the single quotes with double quotes: filelist=$(grep "$incstring" -rl --include=*.{h,cpp} pathToFiles)

Categories : Shell

How to keep blank lines in the end of a file when I user cat command in shell script
You don't need cat command here, directly use awk like this: awk 'END {print NR}' a.txt Your problem is in storing the cat's output in a shell variable. Even this will give right output (though case of UUOC): cat a.txt | awk 'END {print NR}' Update: When you try to do this: a=`cat a.txt` OR else: a=$(cat a.txt) Pitfall is that the process substitution i.e. command inside reverse quote like you have or in $() strips trailing newlines. You can do this trick to get trailing newlines stored in a shell variable: a=`cat a.txt; echo ';'` a="${a%;}" Test the variable value: echo "$a" printf "%q" "$a" Then output will show newlines as well: jhasdfj sdfjalskdf $'jhasdfj sdfjalskdf '

Categories : Linux

Want to store a string into a file, with the filename being the output of a command in shell
You can do the following: name="$(date +'%d%m%Y-%H-%M')_$(whoami)" echo "Sample string" >> $name Then we have: $ ls -ltr -rw-rw-r-- 1 me me 6 Jun 24 17:00 24062013-17-00_me Your user=$whoami was not working because it should be user=$(whoami). In general, to store a command output you have to do variable=$(command).

Categories : Linux

Quickly accessing file names listed by the ls command on Linux shell
Use wildcard expansion, i.e. for the second file: vim *v04*41* or, if your shell supports it, tab-completion: type vim M; press [Tab], that completes all up to next difference, i.e. OD11A1.A2012193.h12v0; type 4; press [Tab], and so on.

Categories : Linux

Piping output from 1 command to other command in an adb shell command line
One way is to create a shell script containing the commands you want and then run the shell script. Since the Android root filesystem is not writeable at run time (usually, unless you have rooted your device and remount it), you can copy the file to the removable (or emulated) storage, for example /sdcard. Then run the script using the command adb shell sh /sdcard/your-script-name. Because each script runs in its own subshell, both of your commands will be executed in the same shell on the device (you can confirm it with ps).

Categories : Android

Running two node servers from a single shell command using a shell script
Your command does not work because you are trying to have two processes running in the same shell. Instead, you should 'spawn' the node processes into different processes. Try this command: node project/rest.js & node static-server.js &

Categories : Node Js

What determines where a System.out.println(args) command prints to?
From the Javadocs for System.out: The "standard" output stream. This stream is already open and ready to accept output data. Typically this stream corresponds to display output or another output destination specified by the host environment or user. In most computing environments, there are three standard streams associated with a process. Note, however, that System.out can be reassigned in Java, by using System.setOut().

Categories : Java

Unable to print an iframe on IE using JavaScript, prints parent page instead
I was looking for a solution to print Iframes in Internet Explorer. After hours of search i got the solution. it worked for me. Please check the following link http://bytes.com/topic/misc/answers/629926-ie7-printing-iframe-solution document.execCommand('print', false, null);

Categories : Javascript

How to redirect time command output in ksh when invoke shell function with dot command?
I tried to reproduce the issue and was not able to: % cat my.sh #!/bin/ksh echo hi % (time . my.sh) 2>&1 | tee my.log hi real 0m0.00s user 0m0.00s sys 0m0.00s % cat my.log hi real 0m0.00s user 0m0.00s sys 0m0.00s If you are still having this issue - please share your my_function.sh and full shell output.

Categories : Unix

What does it mean in shell when we put a command inside dollar sign and parentheses: $(command)
Usage of the $ like ${HOME} gives the value of HOME. Usage of the $ like $(echo foo) means run whatever is inside the parentheses in a subshell and return that as the value. In my example, you would get foo since echo will write foo to standard out

Categories : Bash

Perls system($command) returns other result than command on shell
You are using double quotes. In double quotes, is special, so only + instead of + is passed to sed. You can use the q() operator to avoid backslashing the backslash: $ssh->cmd(q(head -11 /some/path/to/the/file.xml | tail -1 | sed 's/<[^>]+>//g' | xargs));

Categories : Perl

PHP exec command works in shell and php command line but not on website
You can add the second parameter to help debug, $output will display what the cp command is doing, whether it be an error or not. I would also recommend placing quotes around the files, just in case something with a space gets in there. $src = "/mnt/..."; $dest = "/var/www/..."; exec("cp '$src' '$dest'", $output, $retrun_var); var_dump($output, $retrun_var);

Categories : PHP

How to give o/p of one command to the argument of another command in shell script?
As per what i think the below code should satisfy your need. I only gave a dry run to it. Store the result in a variable and then looping to extract data one by one #! /bin/bash $op = find ./kernel -name *.ko" for zf in $op do cp -rpf $zf tail $zf done

Categories : Linux

Similar command to linux tree command in adb shell
You need to install busybox for android, it will add many well known linux tools to your phone. You need a rooted phone for installing busybox. Check it out here: https://play.google.com/store/apps/details?id=stericson.busybox&hl=fr

Categories : Linux

Translating shell script into Windows command shell script (batch)
for /L makes a count-controlled loop in batch. mkdir remains mkdir. @echo off for /L %%y in (1,1,9) do mkdir week_0%%y mkdir week_10

Categories : Shell

Read / write a file in a shell namespace extension using shell APIs
Try IShellFolder.BindToObject: IStream *stream; if (FAILED(shellfolder->BindToObject (pidl, NULL, IID_IStream, &stream))) return E_FAIL; But I'm not sure if this works with writing files as well.

Categories : Windows

For loop that prints every line to a file. Error
.write only accepts 1 parameter so i think you can do this def write_file(filename, rabbitlist, foxlist, finallist, averagefox, averagerabbit): # Opens File for Data Input outfile = open(str(filename) + ".csv", 'w') # Writes Data to Newly Created File finalresult = " ".join(", ".join(map(str, l)) for l in finallist) outfile.write(str("Day, Foxes, Rabbits, , Average Foxes, Average Rabbits ")) lastline = [0, foxlist[0], rabbitlist[0], " ", averagefox, averagerabbit] for item in lastline: outfile.write(" %s" % item) outfile.close()

Categories : Python

Stack trace prints everything on one line in log file (Java)
You could use Java's Logger. With Logger, this should do the trick: Logger = logger = Logger.getLogger(<YourClass>); logger.log(Level.SEVERE, <your message>, e); If you want to do it the hard way you should keep in mind that getStackTrace() returns an array, so you'll have to process it.

Categories : Java

C - my program prints weird stuff after reading from a file
The part where you assign "" to buf[3] is wrong. You should use single quotes: buf[3] = ''; The reason is that double quotes means a string literal (which is a null terminated char array) and not a char variable.

Categories : C

Java, ObjectOutputStream.writeObject prints random symbols to file
You are serializing the object. It is not meant to be readable in plain text, but to be a binary format that makes it easy to read the object and recreate it in a later execution of the program. If you want to store your objects in plain text, then you need to write the individual fields of your object to the file.

Categories : Java

PhpMyAdmin config.default file prints echo twice and other problems
An easy way to allow/deny access based on IP and user is using the AllowDeny directive of phpMyAdmin. See the FAQ from phpMyAdmin documentation. Also have a look at AllowDeny(order) and AllowDeny (rules) configurations.

Categories : PHP

java after reading text from file, prints will "null" in the beginning
When you concatenate a null reference with a string, it is converted to "null" string, and then concatenation is performed. This is specified in JLS - Section 5.1.11: If the reference is null, it is converted to the string "null" (four ASCII characters n, u, l, l). Now, when you declare an instance or static reference field, without initializing to any value, it will be initialized to default value - null, as in your declaration: private static String str; // This is `null`. Then for the first iteration of the loop: str += sCurrentLine; is equivalent to: str = null + sCurrentLine; // Hence the result. As for your str.indexOf() query, I don't know where you are testing the index, because it should return the index of null that is 0, provided, you used that method after the

Categories : Java

Go: execute shell command
You have to pass the program and the arguments separately. See the signature of exec.Command: func Command(name string, arg ...string) *Cmd So if you want to pass e.g. -v=1, your call probably should look something like: dateCmd := exec.Command(pwd + "/build", "-v=1")

Categories : Bash

How can I de-aliasing `dir` using shell command?
First you ahve to define your alias using this syntax: alias dir=ls Then you can check if it worked out: me@foo:~alias alias dir='ls' alias l.='ls -d .* --color=auto' ... After this works you can simply unalias with: unalias dir I think the dir command is a binary in Ubuntu, you can check this using: which dir If it gives you a path to an executable you know that dir is no alias.

Categories : Linux

how to flush with shell command
No, you should never need it. When a program, such as echo, exits, all output data is automatically flushed. If the program has not exited yet then flushing is an internal matter and nothing to do with the shell.

Categories : C

Execute a shell command through ssh using PHP
Try phpseclib, that'll work. <?php include('Net/SSH2.php'); $server = "myserver"; $username = "myadmin"; $password = "mypass"; $command = "ps"; $ssh = new Net_SSH2($server); if (!$ssh->login($username, $password)) { exit('Login Failed'); } echo $ssh->exec($command); ?>

Categories : PHP

rbenv shell not command
There is this note in the rbenv comment reference for the shell command: Note that you'll need rbenv's shell integration enabled (step 3 of the installation instructions) in order to use this command. Step 3 is: Add rbenv init to your shell to enable shims and autocompletion. $ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile Same as in previous step, use ~/.profile on Ubuntu, ~/.zshrc for Zsh. Did you follow that instruction?

Categories : Ruby

Get command result at adb shell
You should do: $ adb shell 'mkdir /xxx; echo $?' mkdir failed for /xxx, Read-only file system 255 Notice the single quotes, otherwise $? is evaluated before reaching adb.

Categories : Android

Using Wildcards in VBA Shell Command
No. The path is simply passed directly to the shell to execute, and the shell can't execute a path with wildcards in it. What you can do is use the Dir command first (which does allow wildcards) to get the filename you want, then execute it: http://msdn.microsoft.com/en-us/library/dk008ty4%28v=vs.90%29.aspx

Categories : Shell

Piping to a command in Ash Shell
After some more experimentation, the problem was not with the shell at all, but with the implementation of Telnet on Busybox. On my version of BusyBox (1.00rc2), piping anything to Telnet didn't work. echo blah | telnet -yrDumb Should have at least made telnet complain about usage. It didn't. I grabbed the most recent version of inetutils (1.9.1) and compiled its telnet for the TS-7260. It works like a dream (read: it works) now, and is consistent with the behavior I see using telnet and bash on my normal linux box. Thanks for the help!

Categories : Bash

What does "[chS]" mean in the regex of this shell command?
That is part of the shell globbing that selects multiple files. The expression [chS] matches a single character containing the value c, h, or S. So, the glob "*.[chS]" is looking for all files that have the extension .c, .h, or .s

Categories : Shell

PHP Script that searches & prints lines from file. How to avoid printing the same line?
It should work: <?php $filename = 'post_file.php'; $KEYWORDS_to_find = array("keyword1","keyword2"); $i=0; $printed_lines = array(); //added this line foreach($KEYWORDS_to_find as $keyword){ foreach(file($filename) as $fli=>$fl){ if($i>=5) break; if(stripos($fl, $keyword)!==false){ if(!in_array($fl,$printed_lines)) { //added this line $printed_lines[] = $fl; //added this line echo $fl; $i++; } //added this line } } } ?>

Categories : PHP

Bash script that prints out contents of a binary file, one word at a time, without xxd
As I see you shouldn't use '|' or echo, because they are both ASCII tools. Instead I think '>' could work for you. I think devmem is a bash function or alias, so I would try something like this: for (( i=0; i<${num_words}; i++ )) do dd if=${file_name} skip=${i} count=1 bs=4 2>/dev/null 1> binary_file # echo -e "${val}" # Weird output... devmem ${some_address} 32 $(cat binary_file) done "As cat simply catenates streams of bytes, it can be also used to concatenate binary files, where it will just concatenate sequence of bytes." wiki Or you can alter devmem to accept file as input...I hope this will help!

Categories : Linux

Unable to run shell script from php code
Do you get your error message when having done chmod? Make sure that mat.sh has the same owner as your apache2-server-instance otherwise this line exec ("chmod a+x mat.sh", $output, $return); will fail, because only the owner can change permissions.

Categories : PHP



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