Standard input and output units in Fortran 90?

If you have a Fortran 2003 compiler, the intrinsic module iso_fortran_env defines the variables input_unit, output_unit and error_unit which point to standard in, standard out and standard error respectively. I tend to use something like #ifdef f2003 use, intrinsic :: iso_fortran_env, only : stdin=>input_unit, & stdout=>output_unit, & stderr=>error_unit #else #define stdin 5 #define stdout 6 … Read more

How to detect if Console.In (stdin) has been redirected?

You can find out by p/invoking the Windows FileType() API function. Here’s a helper class: using System; using System.Runtime.InteropServices; public static class ConsoleEx { public static bool IsOutputRedirected { get { return FileType.Char != GetFileType(GetStdHandle(StdHandle.Stdout)); } } public static bool IsInputRedirected { get { return FileType.Char != GetFileType(GetStdHandle(StdHandle.Stdin)); } } public static bool IsErrorRedirected { … Read more

What does sys.stdin read?

So you have used Python’s “pre built in functions”, presumably like this: file_object = open(‘filename’) for something in file_object: some stuff here This reads the file by invoking an iterator on the file object which happens to return the next line from the file. You could instead use: file_object = open(‘filename’) lines = file_object.readlines() which … Read more

Read a character from standard input in Go (without pressing Enter)

This is a minimal working example for those running a UNIX system: package main import ( “fmt” “os” “os/exec” ) func main() { // disable input buffering exec.Command(“stty”, “-F”, “/dev/tty”, “cbreak”, “min”, “1”).Run() // do not display entered characters on the screen exec.Command(“stty”, “-F”, “/dev/tty”, “-echo”).Run() var b []byte = make([]byte, 1) for { os.Stdin.Read(b) … Read more

How to make ssh receive the password from stdin

based on this post you can do: Create a command which open a ssh session using SSH_ASKPASS (seek SSH_ASKPASS on man ssh) $ cat > ssh_session <<EOF export SSH_ASKPASS=”/path/to/script_returning_pass” setsid ssh “your_user”@”your_host” EOF NOTE: To avoid ssh to try to ask on tty we use setsid Create a script which returns your password (note echo … Read more

How to pipe input to sublimetext on linux?

Assuming Sublime still doesn’t support opening STDIN, a straightforward solution is to dump the output to a temporary file, open the file in sublime, and then delete the file. Say you create a script called tosubl in your bin directory as follows: #!/bin/bash TMPDIR=${TMPDIR:-/tmp} # default to /tmp if TMPDIR isn’t set F=$(mktemp $TMPDIR/tosubl-XXXXXXXX) cat … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)