Sample Header Ad - 728x90

Unix & Linux Stack Exchange

Q&A for users of Linux, FreeBSD and other Unix-like operating systems

Latest Questions

1 votes
1 answers
3218 views
Manjaro MySQL - mariadb.service fails to start
When trying to start MariaDB with `systemctl status mariadb`, I get: ``` ● mariadb.service - MariaDB 10.3.15 database server Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled) Active: failed (Result: exit-code) since (date) Docs: man:mysqld(8) https://mariadb....
When trying to start MariaDB with systemctl status mariadb, I get:
● mariadb.service - MariaDB 10.3.15 database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since (date)
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/ 
  Process: 2512 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
  Process: 2513 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=/usr/bin/galera_recovery; [ $? -eq 0 ]   && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)
  Process: 2521 ExecStart=/usr/bin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=1/FAILURE)
 Main PID: 2521 (code=exited, status=1/FAILURE)
   Status: "Starting final batch to recover 13 pages from redo log"

[ERROR] Could not open mysql.plugin table. Some plugins may be not loaded
[Note] Recovering after a crash using tc.log
[Note] Starting crash recovery...
[Note] Crash recovery finished.
[ERROR] Can't open and lock privilege tables: Table 'mysql.servers' doesn't exist
[Note] Server socket created on IP: '::'.
[ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
mariadb.service: Main process exited, code=exited, status=1/FAILURE
mariadb.service: Failed with result 'exit-code'.
Failed to start MariaDB 10.3.15 database server.
Having followed various tutorials, I may have made it worse. I cannot run mysql anymore (in the context of mysql < file.sql), since it says mysql: command not found. I have tried removing, reinstalling mariadb and rebooting my computer in between; but I'm out of luck. Any ideas? **EDIT:** Many others seem to be having this problem, . Not sure what else I did next as it has been over a year. I do know that following the installation guide [Arch Wiki](https://wiki.archlinux.org/index.php/MariaDB#Installation) page LINE BY LINE will guarantee a proper install. The formatting of the page made me read over things (important things were small, optional things were bold), but make sure you do that right and your installation should work.
Dr-Bracket (437 rep)
May 30, 2019, 05:26 AM • Last activity: May 3, 2025, 02:08 AM
-3 votes
1 answers
21 views
For 'a%' why is one of the results that could be returned 'z6ra'?
[![enter image description here][1]][1] [1]: https://i.sstatic.net/cbBT1cgY.png For 'a%' why is one of the results that could be returned 'z6ra'?
enter image description here For 'a%' why is one of the results that could be returned 'z6ra'?
Neutron (1 rep)
Jul 24, 2024, 05:42 PM • Last activity: Jul 24, 2024, 05:58 PM
0 votes
2 answers
146 views
Load files in sequential order
I need to load multiple files in my shell script with the same filename but appended in the front of each file name is YYMMDDPERSONNEL Examples: 231102PERSONNEL and 230103PERSONNEL There are many other files in the same directory so filenames are important in the sort. I need to sort files to be loa...
I need to load multiple files in my shell script with the same filename but appended in the front of each file name is YYMMDDPERSONNEL Examples: 231102PERSONNEL and 230103PERSONNEL There are many other files in the same directory so filenames are important in the sort. I need to sort files to be loaded from the oldest to the newest. Currently what I have is only designed to handle one file at a time.
teejay (9 rep)
Nov 7, 2023, 05:05 PM • Last activity: Nov 12, 2023, 08:19 AM
4 votes
3 answers
329 views
check patterns that don't exist in sqlite
I explained a similar situation with plain text files on https://unix.stackexchange.com/questions/29624/grep-huge-number-of-patterns-from-huge-file/30144. Many people there said I should, so now I'm migrating my data to a sqlite database: I have a file from which I extract about 10,000 patterns. The...
I explained a similar situation with plain text files on https://unix.stackexchange.com/questions/29624/grep-huge-number-of-patterns-from-huge-file/30144 . Many people there said I should, so now I'm migrating my data to a sqlite database: I have a file from which I extract about 10,000 patterns. Then I check if the database doesn't contain such patterns. If it doesn't, I need to save them externally in file for further processing: for id in $(grep ^[0-9] keys); do if [[ -z $(sqlite3 db.sqlite "select id from main where id = $id") ]]; then echo $id >>file fi done Since I'm new to SQL, I couldn't find a simple way to do this. Also, this loop is useless as it is 20 times slower than what I achieved with awk on the mentioned URL. Since the database is huge, keeps growing, and I run this loop very frequently, is it possible to make this faster?
admirabilis (4792 rep)
Jan 31, 2012, 12:54 AM • Last activity: Nov 11, 2023, 01:26 PM
3 votes
2 answers
2587 views
Make JSON from SQL query output
I have this database query: ```sql select hostname,size from tableinfo ``` The output is like this: ```none hostname size ------------------------- ----------- host1 28 host2 13 host3 79 host4 28 host5 17 ``` Or, I can make it like this: ```none host1 28 host2 13 host3 79 host4 28 host5 17 ``` I wan...
I have this database query:
select hostname,size from tableinfo
The output is like this:
hostname                   size
------------------------- -----------
  host1                        28
  host2                        13
  host3                        79
  host4                        28
  host5                        17
Or, I can make it like this:
host1                        28
host2                        13
host3                        79
host4                        28
host5                        17
I want to write a shell script that converts this output to JSON, but I don't really know where to begin or what to do. The JSON must be like this:
{
    "data":[
    {  "{#HOSTNAME}":"host1",  "{#SIZE}":"28"  } ,
	{  "{#HOSTNAME}":"host2",  "{#SIZE}":"13"  } ,
	{  "{#HOSTNAME}":"host3",  "{#SIZE}":"79"  } ,
	{  "{#HOSTNAME}":"host4",  "{#SIZE}":"28"  } ,
	{  "{#HOSTNAME}":"host5",  "{#SIZE}":"17"  }
    ]
}
BlackCrystal (786 rep)
Jan 19, 2019, 10:25 AM • Last activity: Nov 10, 2023, 03:28 PM
-1 votes
2 answers
176 views
Running SQL databases offline
I'm running a Debian 10 based distro. As an experiment, I downloaded one of these Wikipedia-like sites which gives you a download size of several gigabytes. I was hoping to run it offline. I don't know if I ever had any experience with `.sql`, maybe 15+ years ago in high school. When unzipped, it ha...
I'm running a Debian 10 based distro. As an experiment, I downloaded one of these Wikipedia-like sites which gives you a download size of several gigabytes. I was hoping to run it offline. I don't know if I ever had any experience with .sql, maybe 15+ years ago in high school. When unzipped, it has a bunch of folders, images is the largest folder, anyway I think the main one is the database.sql which is 3GB. How easy is it to navigate this database offline? Obviously when it runs online, there is a search function, etc. If running something like this is feasible on an offline desktop, what .sql programs need to be installed in order to do it?
1toneboy (465 rep)
Nov 28, 2021, 09:43 PM • Last activity: Oct 21, 2023, 10:46 AM
-1 votes
1 answers
79 views
Why no one thought of the concept of joins before the 70s?
So, let me see if I have my history right: - In 1976, the first system sold as an RDBMS was Multics Relational Data Store. I don't know if it had JOIN, but let's assume it did. - The UNIX command `join` was released in 1979. It imitates SQL's JOIN but it works on plain text files. So my question is....
So, let me see if I have my history right: - In 1976, the first system sold as an RDBMS was Multics Relational Data Store. I don't know if it had JOIN, but let's assume it did. - The UNIX command join was released in 1979. It imitates SQL's JOIN but it works on plain text files. So my question is. If join is relatively useful on plain text, why wasn't something like it developed before? Surely operating systems were dealing with plain text data and "tabular data" to some extent since the late 50s. And I'm sure at some point they would have found it useful to have a ready-made abstraction or tool to combine data from two different files in a meaningful way. So, why didn't the concept emerge before? Are my rose-tinted glasses underestimating the cognitive overhead of joins, with all their Venn diagramness, that is only justifiable when the performance of a RDB is needed? Were people content with merging data in an ad-hoc way? Or was join indeed a stroke of genius?
Sebastian Carlos (262 rep)
Jun 26, 2023, 04:09 PM • Last activity: Jun 26, 2023, 04:59 PM
0 votes
0 answers
778 views
Unix : How to convert HTML output from Shell script
How to display the sql query output to HTML table format output. am having shell script code to display output as html table format. and input is taken form sql query but am not getting the proper output. am getting the heading and data with unstructured it means it is taking the first column value...
How to display the sql query output to HTML table format output. am having shell script code to display output as html table format. and input is taken form sql query but am not getting the proper output. am getting the heading and data with unstructured it means it is taking the first column value only heading other displaying one by one format not displaying the table format. anyone help out to resolve this issue. Thanks in advance. This is my code : # SQL query to retrieve data from the custom table
#!/bin/bash

output_file="output.html"
temp_file="temp.txt"
delimiter="|"

sql_query="SELECT 'REQUEST_ID' AS \"REQUEST_ID\",
    'REQUESTED_BY' AS \"REQUEST_BY\",
    'USER_NAME' AS \"USER_NAME\",
    'REQUEST_DATE' AS \"REQUEST_DATE\",
    'CON_PRG_NAME' AS \"CON_PRG_NAME\",
    'OUTFILE_NAME' AS \"OUTFILE_NAME\",
    'FILE_MOVED_STATUS' AS \"FILE_MOVED_STATUS\",
    'CON_STATUS_CODE' AS \"CON_STATUS_CODE\",
    'ORG_ID' AS \"ORG_ID\"
    FROM DUAL
    UNION ALL
    SELECT TO_CHAR(request_id),
        TO_CHAR(requested_by),
        user_name,
        TO_CHAR(request_date),
        concurrent_program_name,
        outfile_name,
        file_moved_status,
        status_code,
        TO_CHAR(org_id)
    FROM xx_concurrent_stg
    WHERE concurrent_program_name = '$concurrent_program_name'
    AND request_date BETWEEN TO_DATE('$from_date', 'DD-MON-YY') AND TO_DATE('$to_date', 'DD-MON-YY');"

# Run the SQL query and save the output to a temporary file
sqlplus -S apps/apps@EBSDB  $temp_file
SET PAGESIZE 0
SET FEEDBACK OFF
SET HEADING OFF
SET COLSEP "$delimiter"
SET TRIMSPOOL ON

$sql_query

EXIT;
EOF

# Generate the HTML table from the temporary file
awk -v delimiter="$delimiter" '
BEGIN {
    print ""
    FS = delimiter
}
NR == 1 {
    print ""
    for (i = 1; i %s", $i
    }
    print ""
}
NR > 1 {
    print ""
    for (i = 1; i %s", $i
    }
    print ""
}
END {
    print ""
}' $temp_file > $output_file
Arthi (1 rep)
May 25, 2023, 11:22 AM • Last activity: May 25, 2023, 11:31 AM
8 votes
1 answers
6095 views
KrbException: Fail to create credential. (63) - No service creds
I am working on setting up Tomcat 8.0.35 on Ubuntu 16.04 with Oracle Java 1.8.0_91-b14 (not `openjdk`) to use Kerberos authentication when authenticating to our Microsoft SQL database. The issue I am running into is that after running `kinit` as the appropriate user with the appropriate switches: su...
I am working on setting up Tomcat 8.0.35 on Ubuntu 16.04 with Oracle Java 1.8.0_91-b14 (not openjdk) to use Kerberos authentication when authenticating to our Microsoft SQL database. The issue I am running into is that after running kinit as the appropriate user with the appropriate switches: sudo -u tomcat8 kinit -k -t /etc/tomcat8/tomcat8.keytab HTTP/linux-test2.our.domain.local@OUR.DOMAIN.LOCAL I am getting this error in the localhost log from Tomcat: Caused by: GSSException: No valid credentials provided (Mechanism level: Fail to create credential. (63) - No service creds) Caused by: KrbException: Fail to create credential. (63) - No service creds When I run sudo -u tomcat8 klist I get the expected response: root@linux-test2:/home/tbourne# sudo -u tomcat8 klist Ticket cache: FILE:/tmp/krb5cc_111 Default principal: HTTP/linux-test2.our.domain.local@OUR.DOMAIN.LOCAL Valid starting Expires Service principal 06/23/2016 14:33:10 06/24/2016 00:33:10 krbtgt/OUR.DOMAIN.LOCAL@OUR.DOMAIN.LOCAL renew until 06/24/2016 14:33:07 When I capture packets during the Tomcat startup, I see a service/instance name being passed of krbtgt/OUR.DOMAIN.LOCAL. I was expecting this to be the Default Principal mentioned above. When I set the serverSpn option in the database connection string, I get the above results. When I remove the serverSpn option, it uses a different Principal name MSSQLSvc/sql-server.our.domain.local@OUR.DOMAIN.LOCAL. Unfortunately I can't use that name since I will need unique logins (and thereby unique SPNs) for each of our Tomcat instances. Our database connection string looks like this: property.db.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver property.db.jdbcUrl=jdbc:sqlserver://sql-server.our.domain.local:1434;databaseName=DBAUTH2;integratedSecurity=true;authenticationScheme=JavaKerberos;serverSpn="HTTP/linux-test2.our.domain.local@OUR.DOMAIN.LOCAL" I have downloaded the Microsoft JDBC driver version 4.2 and Tomcat is using it. I am at a loss as to why Tomcat isn't sending the proper principal name when authenticating to the database. Any insight would be greatly appreciated. I can post the krb5.ini for Tomcat, the krb5.conf, the jaas.conf and any other configs if they would be helpful.
TimBourne (81 rep)
Jun 23, 2016, 07:49 PM • Last activity: May 8, 2023, 08:27 AM
2 votes
2 answers
1127 views
Split long SQL expression at delimiter
## Context I'm trying to import a dump that have some long lines (8k+ character) with SQL*Plus, so I face the error `SP2-0027: Input is too long (> 2499 characters)`. This is a hard-coded limit and cannot be overcome. ## Expected solution I would like to stream my input in bash and to split lines lo...
## Context I'm trying to import a dump that have some long lines (8k+ character) with SQL*Plus, so I face the error SP2-0027: Input is too long (> 2499 characters). This is a hard-coded limit and cannot be overcome. ## Expected solution I would like to stream my input in bash and to split lines longer than the expected width on the last , (comma) character. So I should have something like
cat my_dump.sql | *magic_command* | sqlplus system/oracle@xe
## Details 1. I know that newer version can accept lines up to 4999 characters but I still have lines longer (grep '.\{5000\}' my_dump.sql | wc -l) 2. It is not really feasible to update the dump by hand 3. I did try to use tr but this split every line wich I do not want 4. I did try to use fmt and fold but it does not seems to be possible to use a custom delimiter 5. I am currently looking on sed but I cannot seem to figure out a regexp that would "find the last match of , in the first 2500 characters if there is more than 2500 characters"
homer (123 rep)
Oct 20, 2020, 09:52 AM • Last activity: Feb 28, 2023, 11:11 PM
0 votes
1 answers
62 views
Sqlite table creation
Is it possible to create tables based on a columns data? I currently have a table named `Exchange` which contains numerous columns ``` ID:NAME:PRICE 1:Stick:12 2:Stone:20 3:Water:1 4:Water:1 ``` But I want to create numerous tables based on the `Name` column and select the rows that contain that nam...
Is it possible to create tables based on a columns data? I currently have a table named Exchange which contains numerous columns
ID:NAME:PRICE
1:Stick:12
2:Stone:20
3:Water:1
4:Water:1
But I want to create numerous tables based on the Name column and select the rows that contain that name and move them to their respective table. So in the above example, the result would be 3 new tables Stick, Stone & Water The table Water would be
1:Water:1
2:Water:1
sql (1 rep)
Feb 25, 2023, 02:10 PM • Last activity: Feb 25, 2023, 03:28 PM
0 votes
2 answers
11029 views
How to write a shell script to run a sql query and send the query results in table format in email?
I need to run a SQL query using SHELL script in PUTTY and send the results in email body in table format with headers along with a message line on top. I have written this so far but I am not able to get results in table format. ``` #! /bin/ksh sqlplus -s user/pass @sid > /dev/null << EOF whenever s...
I need to run a SQL query using SHELL script in PUTTY and send the results in email body in table format with headers along with a message line on top. I have written this so far but I am not able to get results in table format.
#! /bin/ksh
sqlplus -s user/pass @sid > /dev/null << EOF 
whenever sqlerror exit 4;
set newpage 0
set space 0
set feedback off
set head off
set echo off
set pagesize 0
set serverout on
set trimspool on
set linesize 3000
spool $CSVFILE
select * from table;
spool off;	 
exit 0;
EOF
mailx -s "Subject Line" myname@email.com < $CSVFILE
exit 0
The SQL is running fine and data is being saved in CSVFILE. The result I want should be in table format sent to the email address in email body and also involve a message line above table, something like so: EMAIL EXAMPLE WITH ROUGH TABLE There are no errors. But no headers in CSVFILE even after putting SET HEAD ON. I have also tried the 'mail -a (content type)' solution but '-a' gives error.
UserGoogle (1 rep)
Dec 2, 2022, 11:52 PM • Last activity: Dec 4, 2022, 05:07 AM
0 votes
1 answers
991 views
Cannot install Microsoft SQL Server to Ubuntu AWS /lib/x86_64-linux-gnu/libc.so.6: version 'GLIBC_2.30' not found
I am trying to install SQL server onto a Ubuntu machine on AWS and it has been nothing but trouble. I get stuck on the last step, configuring the server after selecting edition and setting an administrator password. I get this message /lib/x86_64-linux-gnu/libc.so.6: version 'GLIBC_2.30' not found....
I am trying to install SQL server onto a Ubuntu machine on AWS and it has been nothing but trouble. I get stuck on the last step, configuring the server after selecting edition and setting an administrator password. I get this message /lib/x86_64-linux-gnu/libc.so.6: version 'GLIBC_2.30' not found. This is for a class, so the version of Ubuntu and the SQL server are fixed and cannot be changed. I have tried half a dozen different instances on AWS but get the same error regardless. enter image description here
Aguso1133 (1 rep)
Sep 24, 2022, 06:24 AM • Last activity: Sep 24, 2022, 07:10 AM
0 votes
2 answers
933 views
Slackware and postgres
I want to install postgres and psql via a Slackbuild and I did so. After installing it I tried running the command as suggested in the readme of the Slackbuild but I get an error upon running it as stated. ``` su postgres -c "initdb -D /var/lib/pgsql/14/data --locale=en_US.UTF-8 -A md5 -W" ``` Shoul...
I want to install postgres and psql via a Slackbuild and I did so. After installing it I tried running the command as suggested in the readme of the Slackbuild but I get an error upon running it as stated.
su postgres -c "initdb -D /var/lib/pgsql/14/data --locale=en_US.UTF-8 -A md5 -W"
Should be one line, it looks like from what you copied and pasted you have su on one line and then the rest of the command on anther line. I'm not sure if that is just a formatting issue on your part, but it really doesn't look like that is the case. Also the error message you report seems to support the idea that your not giving the command on one line, and as such not running the command as the right user etc. I ran it on one file. I tried installing it via the source code and it was very complex so I went back to installing it via the Slackbuild. All is good until I need to run: Code:
su postgres -c "initdb -D /var/lib/pgsql/14/data --locale=en_US.UTF-8 -A md5 -W"
This is what I get when I try to run the above command in multiple manners. It does not execute and I believe this is why Postgres is not working. I decided to ride this one out and learn how to use Slackware, Linux, PSQL and Full Stack so as to maximize my knowledge base and contribute to the Slackware project. I noticed while installing postgres via this blog that certain important yet archiac programs aren't in the Sbo website which I plan on adding. This guy has some interesting blogs on Slackware:*http://www.pmoghadam.com/homepage/HT...esql-epkg.html* Below is my attempts to execute the commands, what do you think is going on?
bash-5.1$ su postgres -c "initdb -D /var/lib/pgsql/14/data --locale=en_US.UTF-8 -A md5 -W"
Password: 
su: Authentication failure
bash-5.1$ sudo postgres -c "initdb -D /var/lib/pgsql/14/data --locale=en_US.UTF-8 -A md5 -W"
"root" execution of the PostgreSQL server is not permitted.
The server must be started under an unprivileged user ID to prevent
possible system security compromise.  See the documentation for
more information on how to properly start the server.
bash-5.1$ su - postgres -c "initdb -D /var/lib/pgsql/14/data --locale=en_US.UTF-8 -A md5 -W"
Password: 
su: Authentication failure
bash-5.1$ su - postgres -c "initdb -D /var/lib/pgsql/14/data --locale=en_US.UTF-8 -A md5 -W"
Password: 
su: Authentication failure
bash-5.1$ su postgres -c "initdb -D /var/lib/pgsql/14/data --locale=en_US.UTF-8 -A md5 -W"
Password: 
su: Authentication failure
bash-5.1$ su postgres -c "initdb -D /var/lib/pgsql/14/data --locale=en_US.UTF-8 -A md5 -W"
Password: 
su: Authentication failure
bash-5.1$ su postgres -c init -D /var/lib/pgsql/14/data --locale-en_US.UTF-8 -A md5 -W
su: invalid option -- 'D'
Usage: su [options] [-] [username [args]]

Options:
  -c, --command COMMAND         pass COMMAND to the invoked shell
  -h, --help                    display this help message and exit
  -, -l, --login                make the shell a login shell
  -m, -p,
  --preserve-environment        do not reset environment variables, and
                                keep the same shell
  -s, --shell SHELL             use SHELL instead of the default in passwd

If no username is given, assume root.



bash-5.1$ su
Password: 
bash-5.1# postgres -c "initdb -D /var/lib/pgsql/14/data --locale=en_US.UTF-8 -A md5 -W"
"root" execution of the PostgreSQL server is not permitted.
The server must be started under an unprivileged user ID to prevent
possible system security compromise.  See the documentation for
more information on how to properly start the server.
bash-5.1# su - postgres

We are upping our standards ... so up yours.
                -- Pat Paulsen for President, 1988

postgres@Bern:~$ postgres -c "initdb -D /var/lib/pgsql/14/data --locale=en_US.UTF-8 -A md5 -W"
2022-03-27 14:57:17.257 GMT  FATAL:  unrecognized configuration parameter "initdb _D /var/lib/pgsql/14/data __locale"
postgres@Bern:~$ postgres -c initdb -D /var/lib/pgsql/14/data --locale=en_US.UTF-8 -A md5 -W
2022-03-27 14:57:30.413 GMT  FATAL:  -c initdb requires a value
postgres@Bern:~$
I don't know why this is not working given the fact I listened to and followed the holy read me. I trust in the Linux way and more importantly Slackware as a deity and magical piece of software. I will continue to search for results. 6.0 / import_db.sh
#!/usr/bin/env sh

dropdb sqlzoo
createdb sqlzoo
psql sqlzoo < data/create_tables.sql
ls
In the directory of a project file that needs to use psql. I receive the following errors:
bash-5.1# cd skeleton
bash-5.1# ls
Gemfile  Gemfile.lock  data  database  import_db.sh  lib  logfile  spec
bash-5.1# ./import_db.sh 
dropdb: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory
	Is the server running locally and accepting connections on that socket?
createdb: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory
	Is the server running locally and accepting connections on that socket?
psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory
	Is the server running locally and accepting connections on that socket?
Gemfile  Gemfile.lock  data  database  import_db.sh  lib  logfile  spec
bash-5.1# startdb
bash: startdb: command not found
bash-5.1# initdb
initdb: error: no data directory specified
You must identify the directory where the data for this database system
will reside.  Do this with either the invocation option -D or the
environment variable PGDATA.
bash-5.1# psql
psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory
	Is the server running locally and accepting connections on that socket?
bash-5.1# 
bash-5.1# nano import_db.sh
Why is this error occurring? Why can't I use psql?
naarter (11 rep)
Mar 27, 2022, 03:10 PM • Last activity: Aug 25, 2022, 11:28 PM
0 votes
1 answers
1305 views
How to update data of a field in an oracle table?
My table name: KEY_PARAMETER It consists two fields named SET_NO. and MES_VAL SET_NO. is fixed which doesn't change but my MES_VAL filed is getting changed is every on minute. My intention is to update this MES_VAL field without deleting its old value. SQL> desc key_parameter; SQL> select SET_NO and...
My table name: KEY_PARAMETER It consists two fields named SET_NO. and MES_VAL SET_NO. is fixed which doesn't change but my MES_VAL filed is getting changed is every on minute. My intention is to update this MES_VAL field without deleting its old value. SQL> desc key_parameter; SQL> select SET_NO and MES_VAL from key_parameter; SET_NO. MES_VAL ------ ------- 2324 12.22 5555 -90.40 65467 89.98 1243 123 6754 12.67 5677 898.55 7853 11.00 9865 449.12 3244 90.33 3545 76.89 After one minute, when the MES_VAL field will be updated. It should be like this. SET_NO. MES_VAL ------ ------- 2324 17.67 5555 -90.5 65467 34,88 1243 88 6754 32,90 5677 227.9 7853 30.6 9865 109.3 3244 23.40 3545 132.8 In the back end, a Unix shell script is running in my Solaris system. Where my updated data is getting saved in a .txt file. I have tried using oracle sqlldr REPLACE command, but what is happening it is deleting it's data and then new data is getting populated into table. For the time being, operator are unable to view any data until new value is getting inserted. Also I have tried insert into command but what is happening instead of updating the field, it keeps the old data which I don't required.
Nainita (2972 rep)
Jun 5, 2018, 09:23 AM • Last activity: Aug 3, 2022, 05:58 PM
0 votes
0 answers
166 views
filewatcher script in ksh script
I wanted to edit a already created filewatcher script with the given logic the source file path is stage path (stage/filewatcherwrap.ksh) there are 4 files in the below given format in stage path 1. abc_xyz_07062022_120648.txt 2. abc_efg_07062022_120648.txt 3. abc_xyz_PQR_07062022_120648.txt 4. abc_...
I wanted to edit a already created filewatcher script with the given logic the source file path is stage path (stage/filewatcherwrap.ksh) there are 4 files in the below given format in stage path 1. abc_xyz_07062022_120648.txt 2. abc_efg_07062022_120648.txt 3. abc_xyz_PQR_07062022_120648.txt 4. abc_efg_PQR_07062022_120648.txt Lets assume :- files 1 and 2 belongs to A files 2 and 3 belongs to B I wanted to write these files to a filewatcher.txt file placed in ../temp path while writing these files, I give the file naming as below, 1. abc_xyz_*.txt 2. abc_efg_*.txt 3. abc_xyz_PQR_*.txt 4. abc_efg_PQR_*.txt here, the * takes the timestamp value while writing to the temp/filewatcher.txt script I wanted to write these 4 files by taking the considering pattern matching technique given below if there are 2 underscores, it should write both the A files -->abc_xyz_07062022_120648.txt -->abc_efg_07062022_120648.txt if there are 3 underscores, it should write both the B files -->abc_xyz_PQR_07062022_120648.txt -->abc_efg_PQR_07062022_120648.txt Can this be done using nested for loop..? if returns 2 then it should write first 2 files to the temp/filewatcher.txt file if returns 3 then it should write last 2 files to the temp/filewatcher.txt file NOTE :- while giving abc_xyz_*.txt (it should not consider abc_xyz_PQR_*.txt file) to check the number of underscores, I have used the below logic in putty ls abc_xyz_*.txt|cut -d "." -f1|rev|cut -d "_" -f3-|awk -F "_" '{print NF}' please help! Thanks in advance..
Jayashree (1 rep)
Jul 6, 2022, 06:58 AM
0 votes
2 answers
3380 views
Sybase query: save output to a file
I&#180;ve created the following script: #!/bin/bash isql -U databasename_dba -P password -b <<EOF! select quantity, date from name_table where numer_id="1234" go quit EOF! Running the script I got the desirable output: user@system$ ./EXECUTE_DAILY_4 [![enter image description here][1]][1] [1]: https...
I´ve created the following script: #!/bin/bash isql -U databasename_dba -P password -b < But now, how can I save this result that I see in my terminal window in a file (.csv for example) Thanks in advance for your help
Lorenzo Castagno (109 rep)
Jul 24, 2019, 10:42 AM • Last activity: Apr 16, 2022, 01:27 AM
0 votes
1 answers
147 views
why when I execute a select it works and when I execute an update the script blocks?
when I try to execute a query of type update the script hangs and the sql console stays still. This command executes all queries in the script: res=$(mysql --defaults-file=conf_file --skip-column-names -e "$query") In case I run the following select, it works without any problem and gives me the cor...
when I try to execute a query of type update the script hangs and the sql console stays still. This command executes all queries in the script: res=$(mysql --defaults-file=conf_file --skip-column-names -e "$query") In case I run the following select, it works without any problem and gives me the correct result query="SELECT field FROM table WHERE id=1 and id_ext=1;" but if I execute this update the sql console remains without going on as if I had not put the ; at the end query="UPDATE field SET data=2 WHERE id=1 and id_ext=1;"
JJWRX (1 rep)
Apr 1, 2022, 08:27 AM • Last activity: Apr 4, 2022, 09:20 AM
2 votes
2 answers
2291 views
How to store query multiple result in shell script variable(Array)?
I'm trying to do a query and store **every row** result in an array element in ksh (maybe bash). I do: result=($($PATH_UTI/querysh " set heading off set feedback off SELECT columnA,columnb FROM user.comunication;")) I have that: row1 = HOUSE CAR row2 = DOC CAT echo "${result[1]}" and it gives me HOU...
I'm trying to do a query and store **every row** result in an array element in ksh (maybe bash). I do: result=($($PATH_UTI/querysh " set heading off set feedback off SELECT columnA,columnb FROM user.comunication;")) I have that: row1 = HOUSE CAR row2 = DOC CAT echo "${result}" and it gives me HOUSE But I would like to get: echo "${result}" gives: "HOUSE CAR"
defekas17 (23 rep)
Oct 28, 2021, 03:47 PM • Last activity: Oct 28, 2021, 04:33 PM
1 votes
3 answers
199 views
Regular expression - SQL manipulation
[pol@fedora data]$ lsb_release -a LSB Version: :core-4.1-amd64:core-4.1-noarch Distributor ID: Fedora Description: Fedora release 34 (Thirty Four) Release: 34 Codename: ThirtyFour I'm trying to convert a sample database file from MS SQL Server to PostgreSQL. So, I'm having two small niggles that I c...
[pol@fedora data]$ lsb_release -a LSB Version: :core-4.1-amd64:core-4.1-noarch Distributor ID: Fedora Description: Fedora release 34 (Thirty Four) Release: 34 Codename: ThirtyFour I'm trying to convert a sample database file from MS SQL Server to PostgreSQL. So, I'm having two small niggles that I can't resolve. shipname NVARCHAR(40) NOT NULL, That's - (**always**) two spaces - identifier (i.e. field name) - always [a-z] - lower case alphabetical - followed by an unknown number of spaces - followed by NVARCHAR(xy) NOT NULL **or** it may be followed by NVARCHAR(xy) NULL and I want to transform this into shipname TEXT NOT NULL CHECK (LENGTH(shipname) <= xy), or shipname TEXT NULL, What I have so far: sed 's/^ [a-z]+[ ]+NVARCHAR([0-9]+) NOT NULL/TEXT NOT NULL CHECK \(LENGTH\((\1) <= (\2)\)/g' So, - ^ is the beginning of the string - followed by two spaces - followed by my field name [a-z]+ - followed by an arbitrary no. of spaces [ ]+ - NVARCHAR([0-9]+) and substitute in TEXT followed by NOT NULL then CHECK(LENGTH(xy) - back reference 1 - <= back reference 2... I've tried various permutations and combinations of the above, but nothing appears to work for me. [pol@fedora data]$ sed 's/^ [a-z]+[ ]+NVARCHAR([0-9]+) NOT NULL/TEXT NOT NULL CHECK \(LENGTH\((\1) <= (\2)\)/g' sed: -e expression #1, char 87: invalid reference \2 on `s' command's RHS Get invalid back reference... **Ideally**, and I stress **ideally**, if the string following NVARCHAR(xy) is NULL and **not** NOT NULL, I don't want any length check - because it doesn't make sense to take the LENGTH of a NULL... this is conditional behaviour - not sure if it's possible in regexps.... p.s. thought this would be trivial. Have data like this: N'Strada Provinciale 1234', N'Reggio Emilia', NULL, N'10289', N'Italy'); I want to change the N' into just plain apostrophe ' (the N' is a SQL Server thing) but I don't want to change the NULL into the empty string, or worse ULL - so I tried: [pol@fedora data]$ sed 's/N\'\'/g TSQLV5.sql but get sed: -e expression #1, char 7: unterminated `s' command I know that I've used sed a lot, but would be open to any awk commands that could perform the tasks required.
V&#233;race (601 rep)
Jun 1, 2021, 02:27 PM • Last activity: Jun 2, 2021, 10:39 AM
Showing page 1 of 20 total questions