I'm trying to index the Pascal files of a project, on Linux (modern Ubuntu).
I've followed the instructions, but I'm very confused because of several factors.
The procedure I've applied is:
$ apt install global exuberant-ctags
$ python3 -m pip install pygments
$ gtags --version
gtags (GNU GLOBAL) 6.6.4
Now, things start to get confusing, because first, there is no gtag.conf anywhere in the system.
There is a /usr/share/doc/global/examples/gtags.conf.gz, which says, at the top:
Basically, GLOBAL doesn't need this configuration file ('gtags.conf'),
because it has default values in itself. [...]
I ignore this comment, and run:
gzip -dc /usr/share/doc/global/examples/gtags.conf.gz > /tmp/gtags.conf
export GTAGSCONF=/tmp/gtags.conf
export GTAGSLABEL=pygments
gtags -v
I can see from the output:
[Sat Aug 13 13:57:58 CEST 2022] Gtags started.
Using configuration file '/tmp/gtags.conf'.
Using configuration label 'pygments'.
Using plug-in parser.
[Sat Aug 13 13:57:58 CEST 2022] Creating 'GTAGS' and 'GRTAGS'.
[1] extracting tags of FILE1.ASM
[2] extracting tags of FILE2.ASM
[Sat Aug 13 13:57:58 CEST 2022] Done.
That no PAS files are included.
I try to follow the instructions from the official tutorial:
find . -name '*.PAS' > /tmp/list
gtags -vf /tmp/list
And the output doesn't include any file, essentially:
[Sat Aug 13 14:01:44 CEST 2022] Gtags started.
Using configuration file '/tmp/gtags.conf'.
Using configuration label 'pygments'.
Using '/tmp/list' as a file list.
Using plug-in parser.
[Sat Aug 13 14:01:44 CEST 2022] Creating 'GTAGS' and 'GRTAGS'.
[Sat Aug 13 14:01:44 CEST 2022] Done.
Now, I try to rename the PAS files to pas (or add .PAS to the gtags.conf file). It seems to get better:
$ gtags -v
[Sat Aug 13 14:04:57 CEST 2022] Gtags started.
Using configuration file '/tmp/gtags.conf'.
Using configuration label 'pygments'.
Using plug-in parser.
[Sat Aug 13 14:04:57 CEST 2022] Creating 'GTAGS' and 'GRTAGS'.
[1] extracting tags of FILE1.ASM
[2] extracting tags of FILE2.pas
[... all relevant files ...]
[Sat Aug 13 14:04:58 CEST 2022] Done.
But gtags seems no to index anything relevant, since this:
$ gtags -vf FILE2.pas
results in a big list of lines marked as not found. ignored.
What confuses me is that it seems that Global is not able to parse Pascal files for some reason, but on the other hand, I don't get any error (which I suppose is relate to Pygments).
The "gtags" command generates the index.
gtags -vf relevant.lst expects a list of files inside relevant.lst.
To query contents of a file, you must use "global" command.
E. g. global -c function_na should give you completed function_name as result (provided there is such function in your code)
Related
Hello I have a Django project hosted on an Apache Ubuntu Google VM. I use git to both update the server code and backup the db files. To avoid having to ssh in and do the repetitive git tasks over and over I am trying to code some buttons on the admin page that will run the git scripts. The way git is setup I need to run git as a specific user to use the correct ssh keys. My thought was to allow www-data to sudo as tris (git user) on a very limited set of commands. I attempted to do this by modifying the sudoers file shown below.
#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
Defaults mail_badpass
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL:ALL) ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
# See sudoers(5) for more information on "#include" directives:
#includedir /etc/sudoers.d
I did as was asked and created a file in /etc/sudeors.d/ called git with the following contents and rebooted the vm:
www-data ALL=(tris) NOPASSWD: /usr/bin/git pull
www-data ALL=(tris) NOPASSWD: /usr/bin/git add db.sqlite3
www-data ALL=(tris) NOPASSWD: /usr/bin/git commit -m "server sync"
www-data ALL=(tris) NOPASSWD: /usr/bin/git push
The test python script that is trying to run these commands is shown below:
commands = [
'cd /home/tris/DjangoSite/;',
'''sudo -i -u tris bash -c '/usr/bin/git add db.sqlite3; /usr/bin/git commit -m "server sync"; /usr/bin/git push;' '''
]
command = ' '.join(commands)
p = run(command,stdout=PIPE,stderr=PIPE,shell=True)
results = f"Push\nargs:\n{p.args}\nstdout:{p.stdout.decode('utf-8')}\nstderr:\n{p.stderr.decode('utf-8')}"
print(results)
and finally this is the error it generates:
[Sun May 02 21:11:48.190725 2021] [wsgi:error] [pid 1412:tid 140452225025600] [remote <IP>:62498] Push
[Sun May 02 21:11:48.190771 2021] [wsgi:error] [pid 1412:tid 140452225025600] [remote <IP>:62498] args:
[Sun May 02 21:11:48.190778 2021] [wsgi:error] [pid 1412:tid 140452225025600] [remote <IP>:62498] cd /home/tris/DjangoSite/; sudo -i -u tris bash -c '/usr/bin/git add db.sqlite3; /usr/bin/git commit -m "server sync"; /usr/bin/git push;'
[Sun May 02 21:11:48.190783 2021] [wsgi:error] [pid 1412:tid 140452225025600] [remote <IP>:62498] stdout:
[Sun May 02 21:11:48.190787 2021] [wsgi:error] [pid 1412:tid 140452225025600] [remote <IP>:62498] stderr:
[Sun May 02 21:11:48.190792 2021] [wsgi:error] [pid 1412:tid 140452225025600] [remote <IP>:62498] sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
[Sun May 02 21:11:48.190796 2021] [wsgi:error] [pid 1412:tid 140452225025600] [remote <IP>:62498] sudo: a password is required
Can someone please help identify which step I did incorrectly or missed? I have been banging my head against this for a while and any help would be appreciated, thanks!
Relevant group memberships:
tris#website:~/$ groups www-data
www-data : www-data
tris#website:~/$ groups tris
tris : tris adm dialout cdrom floppy audio dip video plugdev netdev lxd ubuntu google-sudoers
Requested ls -l /etc/sudoers.d
sudo ls -l /etc/sudoers.d
total 20
-r--r----- 1 root root 144 Apr 27 04:04 90-cloud-init-users
-r--r----- 1 root root 958 Feb 18 00:03 README
-rw-r--r-- 1 root root 295 Apr 30 06:33 git
-r--r----- 1 root root 34 Apr 27 06:42 google-oslogin
-r--r----- 1 root root 43 Apr 27 04:05 google_sudoers
Merging all the commands into a single script then adding the script the sudoers file worked.
This is gtags version 5.7.1, the one packaged with Ubuntu 14.04. This is rather an old version of gtags.
The Linux kernel has a gtags Make target, which ultimately results in the command all_target_sources | gtags -i -f -
-i tells gtags to do an incremental update
-f tells gtags to read a list of source files (to examine for symbols) from the following file. -f - means to read the list from stdin.
all_target_sources is a function that outputs a list of all the relevant .c and .h files.
When I run make gtags, the resulting tags table is empty (GTAGS, GPATH etc all have size of 16 bytes which appears to just be a header).
If I modify the script that generates tags so that it uses the following:
all_target_sources > sources.list
gtags -iv -f sources.list
I get the same result. The added -v gives me this output:
checking /home/me/sources/linux/GTAGS
GTAGS found at '/home/me/sources/linux/GTAGS'.
[Tue Jul 05 10:21:49 BST 2016] Gtags started.
Using default configuration.
Tag found in '/home/me/sources/linux'.
Incremental update.
[Tue Jul 05 10:21:49 BST 2016] Updating 'GTAGS'.
[Tue Jul 05 10:21:49 BST 2016] Updating 'GRTAGS'.
[Tue Jul 05 10:21:49 BST 2016] Updating 'GSYMS'.
Global databases have been modified.
[Tue Jul 05 10:21:49 BST 2016] Done.
But when I then run gtags -iv -f sources.list directly from my shell (using the sources.list left over from the script), I find that a proper tags table is built.
I've dumped the environment from inside the script, and diffed it with my prompt environment, there's no differences that should obviously affect gtags.
Does anyone know of any gtags behaviours that could be causing this?
[meta] Sorry, there's no gtags or gnu-global tag and I don't have the rep to create it.
I haven't found the source of the problem, but after installing the latest version of GNU Global from source, the problem goes away. So I conclude it was probably a bug in old versions of gtags.
I got a log from remote linux computer. It looks like:
2013-10-23T08:19:05+0300 Last login: Wed Oct 23 08:17:38 EEST 2013 from 10.9.167.55 on pts/0
2013-10-23T08:19:05+0300 Last login: Wed Oct 23 08:19:05 2013 from 10.9.167.55^M
2013-10-23T08:19:07+0300 ^[[?1034h-bash-4.1$ date
2013-10-23T08:19:07+0300 Wed Oct 23 08:19:07 EEST 2013
2013-10-23T08:19:08+0300 -bash-4.1$ ls
2013-10-23T08:19:08+0300 ^[[0m^[[01;34m99^[[0m #avail.info ^[[01;34mgmoTemp^[[0m raml21.dtd SNMP4JTestAgentBC.cfg
2013-10-23T08:19:08+0300 an_mainHost_localhost_20131023081654000136.xml #avail.info~ gsh.txt ^[[01;34mresults^[[0m
2013-10-23T08:19:09+0300 ^[[m-bash-4.1$ exit
2013-10-23T08:19:09+0300 logout
But it should be:
Last login: Wed Oct 23 08:17:38 EEST 2013 from 10.9.167.55 on pts/0
Last login: Wed Oct 23 08:19:05 2013 from 10.9.167.55
-bash-4.1$ date
Wed Oct 23 08:19:07 EEST 2013
-bash-4.1$ ls
99 #avail.info gmoTemp raml21.dtd SNMP4JTestAgentBC.cfg
an_mainHost_localhost_20131023081654000136.xml #avail.info~ gsh.txt results
-bash-4.1$ exit
logout
The messy codes are terminal control escape sequences, you can use command "infocmp xterm" and "man terminfo" to get more details.
My question is how can I remove these terminal control escape sequences in the file?
Thanks a lot!
Simple way to remove most parts of the control character is using the command below in vim:
:%s/<escape-key>\[[0-9;]*m/ /g
Press Ctrl+V followed by esc-key for the <escape-key> character above. Everything else is the same literal key as in your keyboard.
i use a pipe or direct sed like this
sed 's/[^[:print:]]\[[^a-zA-Z]*[a-zA-Z]//g' YourFile
I solved this issue using lots of regular expressions according to http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
I'm running rdiff-backup to backup some folders on a remote system.
rdiff-backup root#<REMOTESERVER>::/apps/myapp/shared/system /home/backups/system
echo "$(date): Completed... removing backup data older than 4 weeks"
rdiff-backup --remove-older-than 4W /home/backups/system
echo "$(date): Completed..."
Running this leads to errors though during the --remove-older-than command:
Fatal Error: Found 81 relevant increments, dated:
Wed Aug 29 00:41:47 2012
Thu Aug 30 00:57:49 2012
Fri Aug 31 01:04:03 2012
Sat Sep 1 00:44:59 2012
Sun Sep 2 00:41:49 2012
Mon Sep 3 00:41:39 2012
If you want to delete multiple increments in this way, use the --force.
So yeah, I can probably just put --force on it, but I'd like to understand what's going on here and haven't been able to find much on this problem.
Any ideas?
It's just rdiff-backup making sure you really mean it. The usual workflow for --remove-older-than is to run regularly, removing just the oldest increment. In order to avoid data-loss, rdiff-backup requires you to be really sure before letting you remove multiple increments at once.
I want to view the ORA errors in alertlogfile of past 7 (monday-sunday)days,
by writting in shell scripts.
Can anybody help me.
Thanks
Something like:
sed -n -e '/start_time/,/end_time/ {/ORA/ p}' logfile
or with awk
$ start="Fri Feb 27 08:00:00 2009"
$ end="Fri Mar 6 08:00:00 2009"
$ awk -v prev="$start" -v last="$end" '$0 ~ prev,$0 ~ last' logfile
A more sophisticated script looking for last date entries in ORA file is available here, but also at dba-oracle.com
This does not answer exactly your request but might give you some clues to start your own script.
I want the scripts which give output as follows (one week errors) and it should be mail to my id.
Sat Mar 14 10:30:51 IST 2009
ORA-01157: cannot identify/lock data file 2 - see DBWR trace file
Sat Mar 12 12:35:06 IST 2009
ORA-01110: data file 2: '/u02/oradata/Globe/undotbs01.dbf'
Sat Mar 10 09:54:05 IST 2009
ORA-27037: unable to obtain file status
Sat Mar 08 :15:02 IST 2009
ORA-1157 signalled during: ALTER DATABASE OPEN...
Sat Mar 07 12:35:51 IST 2009
ORA-01157: cannot identify/lock data file 2 - see DBWR trace file