Posts by Alessandro Schneider • 521 points
26 posts
-
0
votes1
answer176
viewsA: Artisan Laravel linux script
There are several ways you can do this, but I’ll explain the two simplest: Alternative 1: Create a php page on your server, example http://your domain/crontab.php put the commands you want to run…
-
0
votes2
answers41
viewsA: I can’t change the value I want from a file through Shellscript
I advise you to do this line by line, as follows: # verifica o número de linhas que o arquivo tem linhas=$(wc -l file | awk '{print $1}') # pega o conteúdo do arquivo e coloca na variável file=$(cat…
shell-scriptanswered Alessandro Schneider 521 -
0
votes1
answer118
viewsA: String Return to Array
After placing the contents of the command inside the variable, vc must declare an array: LISTA=$(sqlite3 banco.db 'select code from Channels') echo $LIST 00 01 02 03 Now vc must declare an array…
-
0
votes1
answer949
viewsA: How to save a variable’s value in a Bash Script function
The only mistake I saw in your code was CIFRA_HEX= openssl rand -hex 8 if you want to put the result of the command inside the variable you must do so CIFRA_HEX=$(openssl Rand -Hex 8) see the…
bashanswered Alessandro Schneider 521 -
0
votes3
answers538
viewsA: Replace a line from a bash script file
With the Sed you can do well, but I prefer to use variables (if the text is short), as follows. Contents of the.txt file cat arquivo.txt aaa bbb ccc 111 222 333 ddd hhh iii I will assume that the…
bashanswered Alessandro Schneider 521 -
1
votes1
answer287
viewsA: How to check if a connection is "sleeping" in php?
Actually this tunnel has nothing to do with PHP, PHP only runs the SSH daemon to create the tunnel, you must add some parameters to the command inside your shell_exec to keep the tunnel active.…
-
2
votes1
answer273
viewsA: How to prioritize the device wifi connection even without internet?
Quiet to do that. you need to have on your wifi network, a web server that responds to requests from android and apple. All devices (smartphones, computers, devices that access the internet) make an…
-
0
votes1
answer79
viewsA: How do a script accept bash script completion?
The easiest way to do this is to include a shell script in /etc/bash_completion. d/. The basic structure of this file is a simple function that executes the completion and then the complete…
-
3
votes3
answers3476
viewsA: Grep with multiple parameters
Follows: diff -y ontem.csv hoje.csv | grep "[|\]" See more in --> https://linux.die.net/man/1/grep You can also use egrep --> https://linux.die.net/man/1/egrep…
-
2
votes2
answers109
viewsA: Find and Replace in bash
From what I understood it would be like updating a backup file. Contents of file 1: A1 B1;10;52;3 A2 B2;12;52;3 A3 B3;10;52;3 A4 B4;10;34;3 A5 B5;10;52;3 A6 B6;10;33;3 A7 B7;08;52;4 Archive content…
-
0
votes1
answer74
viewsA: Remove content between two files
Use the SED, find a pattern in the lines you want to delete sed '/<padrão que contem na linha que deseja excluir do arquivo/d' dicionario.txt >> filtrado.txt…
-
1
votes2
answers139
viewsA: Crontab function does not work
I know two ways to schedule tasks on Crom: 1 - execute the command crontab -e that opened a window giving a slight description of how you can schedule the tasks in cron, where you can simply paste…
-
0
votes1
answer81
viewsA: My Shell script does not work "word Unexpected (expecting "in")"
There’s a simple quote where you shouldn’t have dpkg --configure -a' test him now. #!/bin/bash echo 'Deseja alterar a data e a hora deste computador (S/N) ?' read dataHoras if [$dataHoras == S or…
-
0
votes3
answers259
viewsA: How to get response from 'apt remove' via shell_exec with PHP or Python?
Simple answer, go below. shel_exec('apt remove pacote_exemplo > removed-package.txt'; echo $?); the variable $? returns the return code of the last executed command. If the return code is…
-
1
votes4
answers117
viewsA: Copy one line at a time from the source file to the target files
Diego, sorry for the delay. but I was offline these days. Follow my reply. #!/bin/bash # Limite que será usado no for limit=10 # Diretório de destino dos arquivos dir_dest="/home/mkt/tmp/" # Arquivo…
-
2
votes3
answers861
viewsA: How to recursively rename numbered files by naming other files
If I understand correctly you want to rename all the files txt with the filenames jpg, in the example below I considered that it has the same amount of files of both formats. #!/bin/bash # Pega o…
-
3
votes1
answer180
viewsA: How to enable autocomplete resource for shell script?
The easiest way to do this is to include a shell script in /etc/bash_completion. d/. The basic structure of this file is a simple function that executes the completion and then the complete…
-
1
votes2
answers1690
viewsA: Manipulate Data with Date command
I imagine you want to print the date before printing, the correct command is: date +%Y-%M-%d will have the following output 2017-04-01 Want to declare a variable with the current date... var=$(date…
shell-scriptanswered Alessandro Schneider 521 -
2
votes1
answer619
viewsA: How to get a Mac-Address from a local network IP using . NET Core on Linux?
Friend, please do not know how to answer on . NET but in linux you can discover the mac from an ip with the command arping. Syntax: arping -S -w2000 -i -C1 -R -r | Tail -n1 arping -S 192.168.0.8…
-
0
votes2
answers841
viewsA: Replace "[" with [ using sed
Test there sed -e 's/^"\["/[/' -e 's/"]"$/]/' *.csv
-
1
votes1
answer110
viewsA: Correct reading Linux PID
This is a process only, the PID of the same is in the second column from left to right. The process is java, the rest is parameters. You can get the exact PID number by running the command pidof…
linuxanswered Alessandro Schneider 521 -
0
votes1
answer1006
viewsA: How to make HTTP access available to my apache web service on Linux
Create an account on NO-IP https://www.noip.com/pt-BR and configure, there is a lot of tutorial about it on the net. I imagine your webserver is running on your local network. Now you just redirect…
-
1
votes1
answer298
viewsA: Change server CRON function via PHP
It is possible yes. Create a bash script, for example in /etc/scripts/meu_script to make that kind of change example: #!/bin/bash min=$1 hra=$2 dia=$3 mes=$4 semana=$5 # Caso algum dos parâmetro…
-
2
votes1
answer23
viewsA: Webmail Linux Server
You can use Postfix http://www.postfix.org/ It is an email server, you can edit virtually everything on it.
-
2
votes1
answer133
viewsA: Installing web environment with shell script
I would make a Frufru+ or - like, sorry if there are any mistakes, but I did in the race here. But from what I understand, you can take advantage of the idea #!/bin/bash # Nome do script…
-
0
votes3
answers505
viewsA: Run Mysql command when starting the system
No /etc/init. d, mount it as follows #!/bin/bash ou #!/bin/sh como achar melhor ### BEGIN INIT INFO # Provides: (nome que vc deseja dar ao script) # Required-Start: $exemplo1 $exemplo3 $exemplo3…