Is there any way to configure sqlite3 so that the headers will display by default?
I know I can use .headers on to turn on headers, but I have to keep typing it every time I launch the client because the setting doesn't stick between sessions. I want the headers to be on permanently.
From the fine manual:
INIT FILE
sqlite3 reads an initialization file to set the configuration of the interactive environment.
[...]
If the file ~/.sqliterc exists, it is processed first. can be found in the user's home directory, it is read and processed. It should generally only contain meta-commands.
So just put a file called .sqliterc in your home directory and put this in it:
.headers ON
You can pass arguments in the command line too:
sqlite3 db.db -header -column "select x from y;"
Related
I am working on a project were we need to load flat file eg : (Gemstone_20220325.csv) I have given the source name as (Gemstone_*.csv) in script to search for the file in the path.
But it is failing with error , No such file .
Is that anything I am missing . Any idea on this is much appreciated .
You need to put either exact name or use a file list with the name of the file and then use indirect file type in the session that is reading the file.
You can use a pre session shell command like this ls -1 Gemstone_*.csv>/infa/home/tmp/Gemstone_filelist.txt. Or you can create a shell script too with this command for better control.
in the session that is reading this file, set the property to indirect file type and mention /infa/home/tmp/Gemstone_filelist.txt as file to be extracted.
Infa will pick files one by one and process them.
Once the file gets processed, delete it using a post session command task rm -f Gemstone_*..
Trying to connect to SFTP connection where there are few CSV files placed in folders and want to download multiple files at once
The directory is exports/payroll_exports.
There are 3 files there for now:
vani_payroll_bayshore_21323_232.csv
vani_payroll_bayshore_21344_256.csv
vani_payroll_bayshore_124523_888.csv
How to use a get command where I can write get vani_payroll_bayshore%.csv?
I plan to add the get command to a script like this:
option batch on
option confirm off
open sftp:.... -hostkey= "...."
cd exports/payroll_exports
lcd "\\....."
get ( don't know how to write the wildcard syntax)
close
exit
WinSCP uses the common file wildcard syntax as most other applications.
To match anything of any length, use *.
get vani_payroll_bayshore*.csv
See WinSCP masks documentation.
I currently use s3cmd to download a file from s3. However I'd rather output the contents to STOUT. Do you know a unix tool that can do it?
Thanks, Jan
You'll need to add - to the end of you command arguments to make it redirect the output to STDOUT.
Example : s3cmd get s3://... -
See this thread for more information.
You might also use the --no-progress option to avoid extra information in the output and just get the plain file content
I've tried to change global variable DSQUERY in Solaris with this command:
setenv DSQUERY "SYBSERVER"
but it wasn't persisted. When I entered again in the machine the value was set to the older one.
How can I persist this change?
You have to put this line in your profile file. This file is read when you start a shell, and allows you to set-up some specific settings.
The filename depends on the shell you use and how you connect (with a direct connexion or with a su for example).
It seems you use csh, so you will have to change $HOME/.cshrc and.or $HOME/.login files.
Add your SetEnv command to .cshrc and .login file will do the job.
You have to do it in the user profile files, depending on the shell being used (.login, .cshrc, .bashrc, etc) so that when you log in again, it's executed automatically. There are global versions of those files under /etc for some shells, in case you want that to be applied to all users.
Rgds,
Daniel
I want to write a unix/linux program, that will use a configuration file.
My problem is, where should I put the location of the file?
I could "hardcode" the location (like /etc) into the program itself.
However, I would like it, if the user without privileges could install it (through make) somewhere else, like ~.
Should the makefile edit the source code? Or is it usually done in a different way?
Create some defaults:
/etc/appname
~/.appname
Then if you want to allow these to be overridden have your application inspect an environment variable. e.g.
$app_userconfig
$app_config
Which would contain an override path/filename.
Lastly add a command line option that allows a config to be specified at runtime, e.g.
-c | --config {filename}
It is common to use a series of places to get the location:
Supplied by the user as a command line argument (i.e. ./program -C path/to/config/file.cfg).
From an environment variable (char *path_to_config = getenv("PROGRAMCONFIG");).
Possibly look for a user specific or local version (stat("./program.cfg") or build up a strig to specify either "$HOME/.program/config.cfg" or "$HOME/.program.cfg" and stat that).
Hardcoded as a backup (stat("/etc/program/config.cfg",...)).
keeping a global config file under /etc/prgname is a standard. Also allowing a .local config file for individual users that will override the global settings would allow each user to personalize the program to their preference.
As skaffman says, the canonical locations for things like config files are specified in FHS. There appears to be a convention that a program will read a config file from the directory from which it is run as an alternative to the one in the hard-coded location. You may wish to consider adding a command-line switch that allows a user to specify an alternative config file location, as well.
The makefile shouldn't modify the source directly, but it can pass a folder path/name to the compiler through the -D option. One way to handle it would be to #define something like DEFAULT_PATH to be the default installation path. If the user wants to define a path, the makefile would add -DUSER_PATH=whatever to the compiler options. You would write your code to use USER_PATH if it exists, and DEFAULT_PATH otherwise.