w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Shortcut to running Mac Terminal commands
Use applescript tell application "Terminal" to activate tell application "Terminal" do script ("ls -l") in window 1 do script ("cd /Users/test/Music/iTunes/") in window 1 do script ("ls -l") in window 1 end tell Save apple script as application bundle.

Categories : Osx

Running a .py script from bash, how can I pass a python variable back to the terminal once the .py is done running?
You can write your variable and its value into an ini file from the python script. In Values.ini file my_var="value" After executing python script, just invoke Values.ini using . operator . Values.ini Now your shell variable $my_var will be having the assigned value. The advantage with this method is that you can assign any number of variables like this. var1="value1" var2="value2" var3="value3"

Categories : Python

Run consecutive Commands Linux with java runtime exec
As stated in the Javadoc for Runtime.exec(): Executes the specified string command in a separate process. each time you execute a command via exec() it will be executed in a separate subprocess. This also means that the effect of su ceases to exist immediately upon return, and that's why the whoami command will be executed in another subprocess, again using the user that initially launched the program. su test -c whoami will give you the result you want.

Categories : Java

Java: Running cmd commands (multiple commands with multiple arguments at once)
Why do you want do multiple tasks in one command? e.g. Change to C:, dir and then execute? You can easily club all these tasks to one batch file. That would help you "not" compiling you code again in case some directory structure changes.

Categories : Java

how to invoke sh file in linux terminal using Runtime.getRuntime().exec in java
If your script is marked as executable (chmod +x script.sh), you can invoke it by exec("./script.sh"). Otherwise you can directly call it using exec("sh script.sh").

Categories : Java

Re-installing Linux O.S. and then running bunch of commands in a .sh script , how to stop the script if something fails?
You can check the error code from commands you run #!/bin/bash function test { "$@" status=$? if [ $status -ne 0 ]; then echo "error with $1" exit 255 fi return $status } test ls test ps -ef test not_a_command taken from here for more information Bash Beginner Check Exit Status

Categories : Linux

Linux terminal input: reading user input from terminal truncating lines at 4095 character limit
I do not have a workaround for you, but I can answer question 2. In linux PIPE_BUF is set to 4096 (in limits.h) If you do a write of more than 4096 to a pipe it will be truncated. From /usr/include/linux/limits.h: #ifndef _LINUX_LIMITS_H #define _LINUX_LIMITS_H #define NR_OPEN 1024 #define NGROUPS_MAX 65536 /* supplemental group IDs are available */ #define ARG_MAX 131072 /* # bytes of args + environ for exec() */ #define LINK_MAX 127 /* # links a file may have */ #define MAX_CANON 255 /* size of the canonical input queue */ #define MAX_INPUT 255 /* size of the type-ahead buffer */ #define NAME_MAX 255 /* # chars in a file name */ #define PATH_MAX 4096 /* # chars in a path name including nul */ #define PIPE_BUF

Categories : Linux

Java "NoClassDefError" while running the program on Linux
NoClassDefFoundError in Java comes when Java Virtual Machine is not able to find a particular class at runtime which was available during compile time. For example if we have a method call from a class or accessing any static member of a Class and that class is not available during run-time then JVM will throw NoClassDefFoundError. It’s important to understand that this is different than ClassNotFoundException which comes while trying to load a class at run-time only and name was provided during runtime not on compile time. Many Java developer mingle this two Error and gets confused. In short NoClassDefFoundError will come if a class was present during compile time but not available in java classpath during runtime. Normally you will see below line in log when you get NoClassDefFoundErr

Categories : Java

running linux command txl from java program
you can find here what every parameter in ls do: -c with -lt: sort by, and show, ctime (time of last modification of file status information) with -l: show ctime and sort by name otherwise: sort by ctime in order to execute a program in java and wait for it to finish you can use this post

Categories : Java

How to use terminal commands to sign android app
On the same page that you referenced in the question there is an example command for signing an apk. Sign your application with your private key When you have an application package that is ready to be signed, you can do sign it using the Jarsigner tool. Make sure that you have Jarsigner available on your machine, as described in Basic Setup. Also, make sure that the keystore containing your private key is available. To sign your application, you run Jarsigner, referencing both the application's APK and the keystore containing the private key with which to sign the APK. The table below shows the options you could use. Generate a key store $ keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000 Sign an apk. $ jar

Categories : Android

Running java file with external jars in linux
If you are running on linux, then there should be different directory structure from windows. Also the classpath on linux should contains paths separated path by colon(:) instead of semi-colon(;) Put your jars in a directory on linux machines, may be in /var/tmp/myjars. And then compile your code using the below command: javac -cp /var/tmp/myjars/lib1.jar;/var/tmp/myjars/lib2.jar Application.java EDIT As you have updated your question. You need to run your class on windows as mentioned here. I am taking few assumptions here that your Application class is in com.example package. If that is the case then you can run it from the folder containing the com folder as mentioned here: java -cp C:/lib/lib1.jar;C:/lib/lib2.jar com.example.Application

Categories : Java

Running python script on crontab is causing permissions errors but running via terminal is fine
@Lucas Ou-Yang @Hyperboreus as Hyperboreus said it depends on the user privilege who run it . i think that if you give the /tmp/ dir a 777 permission from the root account it'll be fixed : chmod 777 -R /tmp/ okay try with : chmod 777 /tmp/ if the error still check if the directory /tmp/ exist !

Categories : Python

How-to open a splitted terminal with commands in it automatically
You can configure screen to start with two windows, each running a command. For example, try cat > scr <<'EOF' split screen less /etc/hosts focus screen less $HOME/.bashrc EOF screen -c scr See man screen for details.

Categories : Linux

How to run AT commands in Android terminal as root user?
You can use the program atinout which will allow you to easily send AT commands from the commands line. Example to hang up a call: $ echo ATH | atinout - /dev/ttyACM0 - ATH OK $ You need to find the name of the serial device for android (on desktop linux it is typically /dev/ttyACM0 but Android use something different as far as I remember).

Categories : Android

Importing Git Repositories into Linux Eclipse (3.8) and Running/Compiling Them as Java Projects
go through this way: eclipse>right click on project>build path>configure. here you will see a tab called library, library>"add library">"jre system library" you will see as option which jre you want to add. you select execution environment as what ever jre u have installed. thats it.

Categories : Java

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

pass object to another JVM using serialization - same Java version and jars (both running our app)
Serialize any Serializable object with to a byte array Yes. and make a string. No. Exact statements see below os = new ObjectOutputStream(new ByteArrayOutputStream()); os.writeObject(o); s = os.toString(); // s = Base64.encode(s);//Need this some base 64 impl like Apache ? s = URLEncoder.encode(s, "UTF-8"); These statements don't even do what you have described, which is in any case incorrect. OutputStream.toString() doesn't turn any bytes into Strings, it just returns a unique object identifier. Base64 output of 1. The base64 output should use the byte array as the input, not a String. String is not a container for binary data. See below for corrected code. ByteArrayOutputStream baos = new ByteArrayOutputStream(); os = new ObjectOutputStream(baos); os.writeObjec

Categories : Java

How to set the terminal title to show the current running command while it's running and to show it in brackets once it's finished?
You can (ab)use PS1 by putting the same escape sequence in so that every time the prompt is printed, the title gets updated. export PS1="33]2;[$(history 1 | sed 's/^[ ]*[0-9]*[ ]*//g')]07$PS1" The final PS1 just keeps your old prompt for the actual command line. I don't actually use this, but it should work.

Categories : Linux

How to execute a terminal script in Linux from a php file
To run a shell command with PHP, use shell_exec. It will run as the web user (say, www for Apache), so that user will need to have appropriate permissions. You could, of course, use sudo to get around that - but that is extremely insecure and a very, very bad idea. So if you had, e.g. a shell script called shellscript.sh sitting on yoru server, and you've written it to do whatever you need it to do, you could run it in php with: shell_exec('sh path/to/shellscript.sh') However - I'm not sure I correctly understand what you're trying to do, but it seems to me this is a hacky, very inefficient way to go about things, and it's very likely there is a much smoother solution. Even so, good luck.

Categories : PHP

Why can't I execute some command in Linux without any output in the terminal?
> redirects STDOUT. 2> redirects STDERR. &1 redirects to STDOUT. | transfers STDOUT to STDIN for the new process. Did you try: rmdir * > /dev/null 2> /dev/null Which redirects both STDOUT and STDERR to the null device.

Categories : Linux

Configuring Android to use in terminal for Linux Mint
If ADB is properly in your path, the android command should launch the SDK updater. Here is what I have in my .bashrc # SDK PATH=${PATH}:~/android-sdk/tools PATH=${PATH}:~/android-sdk/platform-tools

Categories : Android

Transfer files from terminal in linux (ubuntu)
scp file1 file2 file3 user123@my.server.com.mx: or if installed : rsync -avP file1 file2 file3 user123@my.server.com.mx: if no path is specified after the :, the files will reside in the remote HOME : /home/user123

Categories : Linux

Clearing output of a terminal program in Linux C
Could you clarify the question. Its not so clear. Anyway, i tried answering for what is best expected here. printf("AAAAAAAAAAAAAA"); printf("BBBBBBBBBBBBBB"); printf("CCCCCCCCCCCCCC"); //printf("DDDDDDDDDDDDDD"); comment the last line or delete if you dont want to display in terminal. printf("xxxx") is the statement used for printing output in terminal.

Categories : C

Is there a typeahead buffer for key presses in Linux terminal?
You should read up on VT100 escape sequences. You've discovered that the character code for the escape button (which is sent as a real character, but tends to be used almost exclusively for signalling the beginning of an escape sequence) is 0x1b. To move the cursor UP: <ESC>[{COUNT}A To move the cursor DOWN: <ESC>[{COUNT}B To move the cursor RIGHT: <ESC>[{COUNT}C To move the cursor LEFT: <ESC>[{COUNT}D You can test these yourself by typing them into the terminal. Just type the keys one after another. My terminal does not recognize the count argument, but will work successfully if I type <ESC>[X (for X in A,B,C,D). If your terminal isn't in VT100 mode, look up the escape sequences for whichever mode it's in. You might realize that depending too muc

Categories : Linux

Calculate latency for touch screen UI running on ARM controller board running Linux
There are 3 latencies involved in the above scenario 1. Time taken for the touchscreen to register the finger and raise an input-event. Usually a few milliseconds. Enable FTRACE and log the following with timestamps -- ISR -- Entry of Bottom-half -- Invoking of input_report() 2. Time taken by the app responsible for the GUI to update it. Depending upon the app/framework, usually the most significant contributor to latency. Add normal console logs with timestamps in the GUI app's code -- upon receiving the input event -- just before the command to modify the GUI 3. The time taken by the display to update. Usually within 15-30 milliseconds The final latency is a sum-total of the above 3 latencies.

Categories : Linux

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

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

"Bad configuration option" on linux terminal, during bitbucket ssh connection.
It looks like your ssh-config file /root/.ssh/config contains configuration for git which should be in /home/peter/Dropbox/C++/Qt/sql/.git/config ssh and git is two different programs. They interact with eachother but are configured seperately. It also looks like you're using dropbox to store your git-repo. This can cause problems, to cite the help at #git@freenode: ` 12:19 <iveqy> !dropbox 12:19 -gitinfo(jast@infobot.gitrecipes.de)- Storing git repositories on DropBox is a Very Bad Idea™. Use a free hosting service (such as Bitbucket or GitHub), or read !dropbox_why if you insist upon having your repo corrupted. 12:19 <iveqy> !dropbox_why 12:19 -gitinfo(jast@infobot.gitrecipes.de)- git uses a lot of frequently-changed small files, which dropbox's synchronization

Categories : GIT

iReport runs in linux terminal but no with PHP exec command
Well, finally I found the error, after searching a lot I came to find this post (http://blog.codyjung.com/2011/05/29/problems-with-lampp-and-exec/) It turns out that lampp uses his own libraries, so I got to override /opt/lampp/lib/libgcc_s.so.1 library with the server one (/lib/libgcc_s.so.1), restart apache, and it works right away.

Categories : PHP

Can I use emacs on my computer to compile C code via ssh to a linux terminal?
I'm not sure I understand all your requirements, but all the following can be done: Install Emacs on your machine; install a C compiler on your machine; and do all your work locally. Do all the work remotely in putty (as you've been doing, apparently). Install Emacs locally, to edit and compile remote files (i.e. the files stay on the GNU/Linux server and are compiled there, but you edit them in your local Emacs, via Tramp which internally accesses them via ssh). You can install precompiled binaries for the above, or you can compile them yourself. Even better, you can install GNU/Linux on your machine, so that installing Emacs or a C compiler is then a simple matter of "aptitude install gcc emacs".

Categories : Linux

How to color Linux terminal foreground and background text
You could use ANSI escape codes in your program output. And if you are coding the terminal emulator, you should make it understand those ANSI escape codes.

Categories : Linux

Launch selenium webdriver test from terminal in linux
I use the Junit ant task to run my tests. It will run my tests and print a nice looking html report at the other end for clear results.

Categories : Java

How to get the output of a linux command at the same time it's printed on the terminal?
Start by taking a look at ProcessBuilder, it will save you a lot of hassles when it comes to generating processes. Basically, you need to get the processes's InputStream and read it. This is connected to the processe's standard out. You can use ProcessBuilder to redirect standard error through this stream as well, which will make life a lot easier... And some examples... Runtime.getRuntime().exec to pass parameter when prompted Running a java program from another java program How do I execute DOS commands in Java? I'm not getting any output and probably the machine hangs with the code

Categories : Java

Calling MATLAB through Python but through Linux Command Terminal
You need to quote the string properly. Try: os.system('matlab -nojvm -nodisplay -nosplash -r "ReadFates5mm;quit"') OR os.system("matlab -nojvm -nodisplay -nosplash -r 'ReadFates5mm;quit'") Alternately, you can escape the nested double quotes. os.system("matlab -nojvm -nodisplay -nosplash -r "ReadFates5mm;quit"") Explanation: In your code, os.system("matlab -nojvm -nodisplay -nosplash -r "ReadFates5mm;quit"") 1 1' 22' The double quote started at marker 1 ends at the market 1' & the quote started at 2 ends at 2'. Basically, you need to escape the " at 1' & 2, using ". Alternately, you can use other quote character, '. For more details, search for "string quoting & escape characters". http://en.wikip

Categories : Python

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

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

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

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

How to let terminal window be closed automatically in a linux Console Application when run by IDE
It is actually made for you. If you build executable of your application and run it from terminal (outside of IDE), it (your application... not the terminal) will close after execution (return in main). CodeBlocks uses smth called cb_console_runner to run executables and wait for ENTER to close terminal. I am not sure how is it possible to make it work without cb_console_runner EDIT: In codeBlocks... remove/rename cb_console_runner in /bin and it is solved:) to make it easier: run this command: sudo mv /bin/cb_console_runner cb_console_runner_s

Categories : C++

Linux Terminal: typing feedback gone, line breaks not displayed
Execute the command "reset" and your terminal should be restored Reference: http://www.commandlinefu.com/commands/view/32/salvage-a-borked-terminal This issue happens generally when dumping binary data to the terminal "STDOUT" which when the escape codes received are processed can do anything from change the color of the text, disable echo, even change character set. The easy way to avoid this is to ensure you do not dump unknown binary data to the terminal, and if you must then convert it to hexadecimal to ensure it doesn't change the terminal settings.

Categories : Linux



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