Hi,
I was playing with shell scripting, when a strange thing happened. I need someone to explain it.
I have a file 'infile', contents:
line one
line2
third line
last
a test script test.sh, contents:
read var1
echo $var1
i executed:
cat infile | ./test.sh
output was
line one
Then I did:
cat infile | read var1
echo $var1
Result: a blank line.
I even tried
cat infile | read var1; echo $var1;
same result.
why does this happen?
I've got my computer set up in Japanese (hey, it's good language practice), and everything is all fine and dandy... except javac. It displays localized error messages out to the console, but they're in Shift-JIS, not UTF8:
$ javac this-file-doesnt-exist.java
javac: ?t?@?C??????????????: this-file-doesnt-exist.java
?g????: javac <options> <source files>
?g?p?\??I?v?V?????~??X?g?????A-help ???g?p????
If I pipe the output through nkf -w, it's readable, but that's not really much of a solution:
$ javac this-file-doesnt-exist.java 2>&1 | nkf -w
javac: ????????????: this-file-doesnt-exist.java
???: javac <options> <source files>
????????????????????-help ??????
Everything else works fine (with UTF8) from the command-line; I can type filenames in Japanese, tab-completion works fine, vi can edit UTF-8 files, etc. Although java itself spits out all its messages in English (which is fine).
Here's the relevant bits of my environment:
LC_CTYPE=UTF-8
LANG=ja_JP.UTF-8
From what it looks like, javac isn't picking up the encoding properly, and java isn't picking up the language at all. I've tried -Dfile.encoding=utf8 as well, but that does nada, and documentation on the localization of the JVM toolchain is pretty nonexistent, at least from Google.
I have vimx installed, so I can copy in vimx to the x clipboard by using "+y and the like, which works well as long as I can keep the current vimx running.
However, I also love to be able to switch to the current running shell with ctrl-z and be able to paste what I copied from vim into the shell. Does anyone know how to do this, because as soon as I suspend vim with ctr-z the x-clipboard becomes empty, until I put vim into the fg again.
I used Term::shellUI module and almost every thing
is working as expected but the issue is when I pressed ctrl+c I want to
print "Please use ctrl+d to exit the shell" ,
for that I handle the signal but the message print only after I pressed the new line
how to resolve this !
Thanks in advance !
So I'm going through the matplotlib documentation and prepared to use the iPython interactive Python shell with ipython -pylab. However I get this:
Az's MBP:~ Az$ ipython -pylab
-bash: ipython: command not found
Did I fail to install iPython? I used easy_install as advised.
Any ideas?
The first error is a warning for complier 'com.apple.compilers.gcc.4_0' I don't know if this is okay and I can just not worry about it.
The second tells me that my entitlements file is no longer at that location. I know this and I thought I had correctly updated it in Xcode's info window. This project builds fine in Xcode.
Michael-Lindahls-Mac:~ michaellindahl$ xcodebuild -project /Users/michaellindahl/Dropbox/Xcode/App/app.xcodeproj -alltargets
2011-01-03 11:41:51.591 xcodebuild[15162:60f] warning: compiler 'com.apple.compilers.gcc.4_0' is based on missing compiler 'com.apple.compilers.gcc.4_0'
=== BUILD NATIVE TARGET app OF PROJECT app WITH THE DEFAULT CONFIGURATION (Release) ===
Check dependencies
[BEROR]CodeSign error: The entitlements file '/Users/michaellindahl/Dropbox/Xcode/deletedAppFile/Entitlements.plist' is missing
** BUILD FAILED **
How do I prevent access to a php script if not called with a comandline application like curl? I'm working on a web application and it uses a cron script to run it's services.
I want to be able to save a data stream which i am returning using the curl command. I have tried using the cat command, and piping it the curl command, however i'm doing it wrong.
The code im currently using is:
cat > file.txt | curl http://datastream.com/data
Any help would be appreciated.
Hello
I've been trying for an hour to run the following program with a the postgresql classpath
class Test{
public static void main(String[] args){
try {
Class.forName("org.postgresql.Driver");
} catch (ClassNotFoundException cnfe) {
System.err.println("Couldn't find Postgresql driver class!");
}
}
}
The program compiled fine with the javac command, but I'm having a hard time running it with the postgresql classpath. I have "postgresql-9.0-801.jdbc4.jar" in the same directory as the file and I tried the following, but non of them worked
java -classpath ./postgresql-9.0-801.jdbc4.jar Test
java -classpath postgresql-9.0-801.jdbc4.jar Test
java -classpath "postgresql-9.0-801.jdbc4.jar" Test
What am I doing wrong?
Regards!
I have a Perl script that requires the user to enter a password. How can I echo only '*' in place of the character that the user types, as they type it?
I'm using Windows XP/Vista.
I'm looking for an explanation of the different functionality in versions of a application called VMAC (Verix blah blah blah), also called "comm server", which is used on Verifone payment terminals. I've got terminals with versions 1.7 and 3.3 of VMAC, and I'm unaware of the differences.
If someone is a Verifone expert, it would be helpful to know how much of the communication with the processing host vs the merchant services provider's application.
What is the right way to stop an endless while-loop with a Term::ReadLine::readline?
This way I can not read in a single 0
#!/usr/bin/env perl
use warnings;
use strict;
use 5.010;
use Term::ReadLine;
my $term = Term::ReadLine->new( 'Text' );
my $content;
while ( 1 ) {
my $con = $term->readline( 'input: ' );
last if not $con;
$content .= "$con\n";
}
say $content;
and with
last if not defined $con;
the loop does never end.
I am working around a problem in Ubuntu 10.04 where after resume, the mouse cursor disappears.
This can be "fixed" by running chvt 1; chvt 7 in a script in /etc/pm/sleep.d, such that those commands run on thaw and resume.
However, the X console is not always vt #7, so chvt 7 is wrong in those cases.
What I would like to do is find out the current vt in the fix-up script and make sure I change back to that vt.
How can I find the current vt? (tty(1) just reports "not a tty")
Hi all,
when I try to copy any file with scp on Mac OS X Snow Leopard from another machine I get this error:
scp [email protected]:/home/me/file.zip .
Password:
...
---> Couldn't open /dev/null: Permission denied
this is the output of "ls -l /dev/null":
crw-rw-rw- 1 root wheel 3, 2 May 14 14:10 /dev/null
I am in the group wheel, and even if I do "sudo scp..." it doesn't work. It's driving me crazy, do you have any suggestion?
Thanx!
dyld: Library not loaded: /opt/local/lib/libncursesw.5.dylib
Referenced from: /opt/local/bin/clear
Reason: image not found
Trace/BPT trap
This is what my bash_login looks like:
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
export PATH="/usr/local/apache-maven-2.2.1/bin:$PATH"
export PATH="~/.gem/ruby/1.8/bin:$PATH"
export PATH="/usr/local/mysql/bin:$PATH"
export PATH="/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home/bin:$PATH"
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
export MANPATH=/opt/local/share/man:$MANPATH
I have some proxy settings that I only occasionally want to turn on, so I don't want to put them in my ~/.bash_profile. I tried putting them directly in ~/bin/set_proxy_env.sh, adding ~/bin to my PATH, and chmod +xing the script but though the script runs, the variables don't stick in my shell. Does anyone know how to get them to stick around for the rest of the shell session?
I have a number of .css files spread across some directories. I need to find those .css files, read them and if they contain a particular class definition, print it to the screen.
For example, im looking for ".ExampleClass" and it exists in /includes/css/MyStyle.css, i would want the shell command to print
.ExampleClass {
color: #ff0000;
}
Hi, I am trying to execute a program from the Java code. Here is my code:
public static void main(String argv[]) {
try {
String line;
Process p = Runtime.getRuntime().exec(
"/bin/bash -c ls > OutputFileNames.txt");
BufferedReader input = new BufferedReader(
new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null) {
System.out.println(line);
}
input.close();
} catch (Exception err) {
err.printStackTrace();
}
}
My OS is Mac OS X 10.6.
If I remove the "> OutputFileNames.txt" from the getRuntime().exec() method, all the file names are printed on the console just fine. But I need it to be printed to a file.
Also, if I change the command to:
Process p = Runtime.getRuntime().exec(
"cmd \c dir > OutputFileNames.txt");
and run it on Windows, it runs and prints the results in the file perfectly fine too.
I have read the other posts for executing another application from Java but none seemed to relate to my problem.
I would really appreciate any help I can get.
Thanks,
Is there a way in python to programmatically determine the width of the console? I mean the number of characters that fits in one line without wrapping, not the pixel width of the window.
Edit
Looking for a solution that works on Linux
Short Question
What's the right way to handle a Ctrl-C event sent over Telnet on the server side?
Long Question
After calling recv() on a socket, I'd like to handle some situations appropriately. One of them is to return a certain error code when Ctrl-C was received. What's the correct way to detect this? The following works, but it just doesn't seem right:
size_t recv_count;
static char ctrl_c[5] = {0xff, 0xf4, 0xff, 0xfd, 0x06};
recv_count = recv(socket, buffer, buffer_size, 0);
if (recv_count == sizeof(ctrl_c) &&
memcmp(buffer, ctrl_c, sizeof(ctrl_c) == 0)
{
return CTRL_C_RECEIVED;
}
I found a comment on Ctrl-C in a side-note in this UNIX Socket FAQ:
[...] (by the way, out-of-band is often used for that ctrl-C, too).
As I understand, receiving out-of-band data is done using recv() with a certain flag as the last parameter. But when I'm waiting for data using recv() as I do in the code above, I can't read out-of-band data at the same time. Apart from that, I'm getting something using recv() without that oob-flag.
I wrote an application that, among other things, launches some "backend" processes to do some stuff.
These subprocesses are very likely to fail or have unexpected behavior since they have to operate in quite hard conditions, so I prefer to give full control over them to the operator.
NOTE: I am running these processes using a subprocess module based class instead of QProcess to have some more control functionality over the running process.
At the moment, I'm using a QPlainTextEdit widget to which I append standard output/error from the subprocess, plus some buttons to quickly send some common signals (INT, STOP, CONT, KILL, ..), but:
In some cases it would be useful to send some input too. Although it could be done with a text input box, I would prefer using something more "professional"
Of course, there is no direct way to interpret special control characters, such as color codes, cursor movement, etc..
I had to implement an auto-scroll management of the console, but it is not guaranteed 100% to work nicely (sometimes the scroll locking doesn't work as expected, etc.)
So: does anyone know something I could use to accomplish these needs?
I found qtermwidget but it seems more oriented on handling a shell process (and the Python bindings seems to let you run /bin/bash only) by itself than communicating with an already existing process I/O.
I am trying to change the working directory when my nodejs script is run from a bin script.
So simplified I have something like:
#!/usr/bin/env node
process.cd('/Users')
When I then run this command like ./bin/nodefile it exits but stays in the same directory it started in.
I have also tried shelljs,
What is the best way to do this? I understand it's working but it's just in a separate process.
Thanks.
I've recently started messing around with Java sockets and telnet...
I want the user to be able to connect to the server, just type a letter and have it sent to the server, without pressing enter to send it. I'm sure there's no way for the server to set this up, but maybe telnet has a parameter or something which could allow this?
Maybe if I got the user to type stty cbreak or stty raw before running telnet, this would work? (UNIX only, I know!)
If I can get telnet to do this then it saves me having to write a special client just for this feature...