1. for example when i run "expo start" it shows the following message:
'expo' n’est pas reconnu en tant que commande interne
ou externe, un programme exécutable ou un fichier de commandes
2. My system variables are set to the following:
Path: C:\Windows\system32; C:\Windows ; C:\Windows\System32\Wbem ;
C:/Users/Microk/AppData/Roaming/npm; C:\Programmes\Nodejs;
C:\Programmes\Git;
pathtext:.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
windir: C:\Windows
3. My user variables are set to the following:
Path:c:\windows\system32; c:\windows ; c:\windows\system32\wbem; c:/Users/Microk/AppData/Roaming/npm; C:\Programmes\nodejs; C:\Programmes\Git;
pathtext:.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
windir: C:\Windows
the solution was to set my enviroment variables to the following:
1. user variables:
path:C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\system32\WindowsPowerShell\v1.0\Modules;C:\Programmes\Nodejs\node.js;C:\Programmes\Git;C:\Windows\System32;C:Wwindows;C:\Windows\System32\wbem;C:\Users\Microk\AppData\Roaming\npm;C:\Users\Microk\AppData\Roaming\npm\node_modules\expo-cli\bin;C:\Programmes\Git;C:\Program Files\nodejs
PATHEXT: %PATHEXT%;.RB;.RBW
node:C:\Programmes\nodejs\node.js
NODE_PATH:C:\Users\Microk\AppData\Roaming\npm\node_modules
2. System variables:
Path:C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\system32\WindowsPowerShell\v1.0\Modules;C:\Programmes\Nodejs\node.js;C:\Programmes\Git;
Related
I am making a batch code to execute commands and capture result in files, while also keeping the output on screen.
For programs with fast execution and simple output of one line after another I have found a solution.
This solution does not seem to work unfortunately with commands that have a progress bar on the screen.
The output of the progress line is spread in the following lines and this is not wanted.
For example this:
#echo off
rem Warning! Run as administrator.
rem go safe place for testing...
cd /D "%temp%"
for %%C in (
"chkdsk /scan"
"dism /online /cleanup-image /scanhealth"
"sfc /scannow"
) do (
rem Partially simulates "echo on" on commands.
echo(%CD%^>%%~C
rem Execute command.
%%~C
)
I would like to keep the original output and keep the time progress on the screen, while on file I would like the final output or in any case the possibility to extract it.
I tried to re-route the output to file but I should re-read and reformat it, maybe there is a better solution.
Is there a way this can be achieved?
I'm open to workarounds involving batch files and PowerShell
i tried to run this command in powershell but the result on screen is not what i want:
PS C:\Users\fposc\AppData\Local\Temp> chkdsk /scan *>&1 | Tee-Object -Variable Tee
Il file system è di tipo NTFS.
L'etichetta del volume è Windows.
Fase 1: analisi della struttura del file system di base in corso...
Avanzamento: 0 di 536592 completati. Fase: 0%, totale: 0%, ETA: 0:25:49
Avanzamento: 1630 di 536592 completati. Fase: 0%, totale: 0%, ETA: 0:25:48 .
Avanzamento: 4549 di 536592 completati. Fase: 0%, totale: 0%, ETA: 0:25:45 ..
Avanzamento: 6765 di 536592 completati. Fase: 1%, totale: 0%, ETA: 0:03:36 ...
Avanzamento: 10756 di 536592 completati. Fase: 2%, totale: 0%, ETA: 0:03:18
Avanzamento: 10803 di 536592 completati. Fase: 2%, totale: 0%, ETA: 0:04:22 .
Avanzamento: 13373 di 536592 completati. Fase: 2%, totale: 0%, ETA: 0:04:30 ..
Avanzamento: 16728 di 536592 completati. Fase: 3%, totale: 1%, ETA: 0:04:12 ...
Avanzamento: 23233 di 536592 completati. Fase: 4%, totale: 1%, ETA: 0:03:39
EDIT
I have tried the answer of Cpt.Whale and this work very well. The output on screen is kept as the original command
C:\WINDOWS\system32>echo chkdsk /scan | powershell -c "Start-Transcript tee.txt -Force; Invoke-Expression $input; Stop-Transcript"
Trascrizione avviata. File di output: tee.txt
Il file system è di tipo NTFS.
L'etichetta del volume è Windows.
Fase 1: analisi della struttura del file system di base in corso...
536592 record file elaborati.
Verifica file completata.
Durata fase (Verifica record di file): 58.78 secondi.
39496 record di file di grandi dimensioni elaborati.
Durata fase (Recupero record di file orfani): 0.00 millisecondi.
...
10504959 unità totali di allocazione su disco.
3520856 unità di allocazione disponibili su disco.
Durata totale: 1.87 minuti (112741 ms).
Trascrizione arrestata. File di output: C:\WINDOWS\system32\tee.txt
C:\WINDOWS\system32>
but the file has problem: look at "´╗┐" and "├¿"
C:\WINDOWS\system32>type C:\WINDOWS\system32\tee.txt
´╗┐**********************
Inizio trascrizione Windows PowerShell
Ora di inizio: 20210425161211
Nome utente: PC-ASUS\fposc
Esegui come utente: PC-ASUS\fposc
Nome configurazione:
Computer PC-ASUS (Microsoft Windows NT 10.0.19042.0)
Applicazione host: powershell -c Start-Transcript tee.txt -Force; Invoke-Expression $input; Stop-Transcript
ID processo: 8476
PSVersion: 5.1.19041.906
PSEdition: Desktop
PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.19041.906
BuildVersion: 10.0.19041.906
CLRVersion: 4.0.30319.42000
WSManStackVersion: 3.0
PSRemotingProtocolVersion: 2.3
SerializationVersion: 1.1.0.1
**********************
Trascrizione avviata. File di output: tee.txt
Il file system è di tipo NTFS.
L'etichetta del volume è Windows.
Fase 1: analisi della struttura del file system di base in corso...
536592 record file elaborati.
Verifica file completata.
Durata fase (Verifica record di file): 58.78 secondi.
39496 record di file di grandi dimensioni elaborati.
Durata fase (Recupero record di file orfani): 0.00 millisecondi.
0 record file non validi elaborati.
Durata fase (Controllo record di file non validi): 0.46 millisecondi.
Fase 2: analisi del collegamento dei nomi file in corso...
72663 record reparse elaborati.
730874 voci di indice elaborate.
Verifica indici completata.
Durata fase (Verifica dell'indice): 47.53 secondi.
0 file non indicizzati analizzati.
Durata fase (Riconnessione orfano): 5.58 secondi.
0 file non indicizzati ripristinati nella cartella dei file persi e ritrovati.
Durata fase (Ripristino orfano nella cartella dei file persi e ritrovati): 6.15 millisecondi.
72663 record reparse elaborati.
Durata fase (Verifica reparse point e ID oggetto): 372.90 millisecondi.
Fase 3: analisi dei descrittori di sicurezza in corso...
Verifica descrittori di sicurezza completata.
Durata fase (Verifica descrittori di sicurezza): 74.18 millisecondi.
97142 file di dati elaborati.
Durata fase (Verifica attributi dati): 0.43 millisecondi.
CHKDSK sta verificando il journal USN...
34812696 byte USN elaborati.
Verifica del journal USN completata.
Durata fase (Verifica journal USN): 352.43 millisecondi.
Analisi del file system effettuata. Nessun problema rilevato.
Non sono necessarie ulteriori azioni.
42019839 KB di spazio totale su disco.
27079516 KB in 285283 file.
189088 KB in 97143 indici.
0 KB in settori danneggiati.
667811 KB in uso dal sistema.
65536 KB occupati dal file registro.
14083424 KB disponibili su disco.
4096 byte in ogni unità di allocazione.
10504959 unità totali di allocazione su disco.
3520856 unità di allocazione disponibili su disco.
Durata totale: 1.87 minuti (112741 ms).
**********************
Fine trascrizione Windows PowerShell
Ora di fine: 20210425161414
**********************
C:\WINDOWS\system32>
These tools all just dump everything to stdout, so the best option is capture everything, then filter out what you don't need. Here's an example using simple regex and a string method. Updated to include all three commands:
# Put all this in a .ps1 file - c:\temp\CmdAndLog.ps1
#Requires -RunAsAdministrator
$commands = (
'chkdsk /scan',
'dism /online /cleanup-image /scanhealth',
'sfc /scannow'
)
Set-Location $env:TEMP
# Iterate through command list
Foreach ($command in $commands) {
# record all output, overwrite existing file
Start-Transcript tee.txt -Force
# Run command string
Invoke-Expression $command *>&1
Stop-Transcript
$tee = Get-Content tee.txt
$result = $tee |
Where {
$_ -notmatch 'Progress' -and # Exclude lines with 'Progress'
$_ -notmatch 'processed' -and # Exclude lines with 'processed'
# ! # Add more filters here if needed
![string]::IsNullOrEmpty($_.trim()) # Exclude empty and whitespace lines
}
$result | Out-File result.log -Append
}
The final amount and complexity of the filters is up to you.
If you need to start it from a batch file for some reason, you can use this to call it:
powershell -f c:\temp\CmdAndLog.ps1
Sorry but i am not familiar with stackoverflow, so i can't make it that understandable, but i hope that this is enough.
I may have misunderstood you, but what I did understand is:
You want to capture the result and send it to text files while still
maintaining the original output on the screen.
You wanted a type of program with fast execution, even if it doesn't
seem to be the case since you are using executables from Windows
itself.
The progress bars keep crashing or, in general, bugging and this
interferes with the files you want to write and makes the output on
the screen look ugly.
You can create an invisible program that is writing the outputs in a separate file and another that is reading those outputs, as in:
Invisible:
code1.bat
#echo off
chkdsk /scan >actual
Visible:
code2.bat
#echo off
:loop
set /p actual=<actual
echo %actual%>>log.txt
echo %actual%
timeout /t 1 >nul
goto loop
Certainly these codes can be improved, but you get the idea.
You can make these codes invisible using the following VBS script:
Set oShell = CreateObject ("Wscript.Shell")
Dim strArgs
strArgs = "cmd /c X:\YOURSCRIPTPATH\YOURSCRIPTNAME.bat/cmd"
oShell.Run strArgs, 0, false
It could also show a command so that you can run everything with administrative permissions, since that is what is needed for commands like chkdsk, but there you go, just ask.
As the progress bars get buggy, it could be a problem with your code page, try to search for the CHCP that's right for you. Perhaps #chcp 1252 is what is needed. Try adding "# chcp 1252 >nul" to the beginning of your code or increasing the size of the console using "mode con lines=xxx cols=xxx"
Finally, about the speed of the batch: Batch script is a utility for the Windows shell. The shell itself is a program to facilitate navigation and the work of people who work with computer concerts with commands like chkdsk itself, so it is not optimized for everyday use, the execution is extremely slow. Make a test, put a loop that only prints 1000 "A" s on the screen in Python and another in Batch. Batch will take 5 ~ 20 seconds, Python will take probably less than milliseconds.
Hope this helps,
K.
This question already has answers here:
Read a file line by line assigning the value to a variable [duplicate]
(10 answers)
I just assigned a variable, but echo $variable shows something else
(7 answers)
Closed 4 years ago.
I have a problem with my script. I tried to read a xml file with cat and read each lines with a loop. For example:
cat file.xml | while read line; do echo $line done
But inside my xml files, i had very long lines without backslash and it seems like cat file.xml didn't take big lines on file. However, when i did cat file.xml without the 'while read line', it works.
Is cat limited by the length of the line? Or did i just do a bad manipulation? What should i do to get these lines?
Thanks and bye.
Here is my script that does not work (in french):
#!/bin/bash
## SCRIPT PERMETTANT DE POUVOIR PRENDRE UNE SOURCE DE TXT POSSEDANT DU TEXTE À CHAQUE LIGNE ET LES PLACER, GRACE À UN MOT CLEF, DANS DES FICHIERS SPECIFIES VIA LE CHEMIN D'ACCESS D'UN FOLDER INDIQUÉ PAR L'UTILISATEUR.
## EXEMPLE ##
## L'utilisateur prend un dossier "X" ou sont contenus des XML. Il a placé dans tous ces XML un mot clé "motclefnumero1". Grace à ce script, il pourra changer ce mot clé par les lignes d'un fichier texte.
#### DEMANDE UTILISATEUR ####
echo 'Quel est le fichier source TXT (Possedant ce que vous voulez mettre)'
read textSource
echo 'Quel est le folder où les fichiers que vous souhaitez traiter sont placés?'
read folderSource
echo 'Indiquer le mot clé souhaité (Exemple : motclef1)'
read motClef
# cat file | cut -c1-80
# TABLEAU CONTENANT LES LIGNES DE NOTRE SOURCE TXT
myArray=()
while IFS= read -r line; do
myArray+=("$line")
done < "$textSource"
i=0
## PROCESS
ls -1 "$folderSource" | while read file; do
cat "$folderSource/$file" | while read texte; do
# Dans le cas où le dossier folderSource n'existe pas
if [ ! -d "$folderSource/resultat" ]; then
mkdir "$folderSource/resultat"
fi
## Effectuer la transputation du texte demandé dans notre texte de remplacement
echo ${texte//$motClef/${myArray[$i]}} >> "$folderSource/resultat/$file"
echo "Line $i : $texte"
## CONSOLE LOG
echo ${myArray[$i]} $folderSource/$file
echo $i
done
## Increment i var
i=$((i+1))
done
RESOLVED :
Hello, i've resolved my problem. Instead of use this :
cat "$folderSource/$file" | while read texte; do
Just use IFS to read each line, it works :
while IFS='' read -r texte || [[ -n "$texte" ]]; do
done < "$folderSource/$file"
I am working with scantailor-cli and I can't get any output images, only the creation of the project with the input images and also without respecting the configuration.
The sample bash script is:
#!/bin/bash
# Este script requiere: xsane, perl-rename, Scan Tailor
impresora="hpaio:/usb/Deskjet_F4400_series?serial=CN01BC111V05C5" # Nombre de la impresora: usar scanimage -L para ver los dispositivos disponibles
dpi=150 # DPI a usar
directorio_padre="scan" # Nombre de la carpeta donde se creará todo
nombre_proyecto="proyecto" # Nombre del proyecto de Scan Tailor
orientacion=left # Orientación para rotar las hojas en Scan Tailor; posibles: left, right, upsidedown y none
plantilla=2 # Tipo de proyecto en Scan Tailor; posibles: 0 (automático), 1 (una sola página), 1.5 (página y media) y 2 (dos páginas)
contenido=normal # Tipo de detención del contenido en Scan Tailor; posibles: cautious, normal y aggressive
margenes=10 # Cantidad de margen que se agregará en todos los lados en Scan Tailor
alineacion_vertical=center # Alienación vertical de los contenidos en Scant Tailor; posibles: top, center y bottom
alineacion_horizontal=center # Alienación horizontal de los contenidos en Scant Tailor; posibles: left, center y right
# Para obtener la ruta absoluta del repositorio; viene de http://stackoverflow.com/questions/59895/can-a-bash-script-tell-which-directory-it-is-stored-in
SCRIPT_PATH="${BASH_SOURCE[0]}";
if ([ -h "${SCRIPT_PATH}" ]) then
while([ -h "${SCRIPT_PATH}" ]) do SCRIPT_PATH=`readlink "${SCRIPT_PATH}"`; done
fi
pushd . > /dev/null
cd `dirname ${SCRIPT_PATH}` > /dev/null
SCRIPT_PATH=`pwd`;
popd > /dev/null
# Va a la carpeta donde está el script
echo "Yendo a «$SCRIPT_PATH»."
cd $SCRIPT_PATH
# Busca si ya existe un directorio con el nombre a utilizar; viene de https://stackoverflow.com/questions/59838/check-if-a-directory-exists-in-a-shell-script
if [ -d "$directorio_padre" ]; then
echo "ERROR: Ya existe el directorio con nombre «$directorio_padre»."
exit
fi
# Indica si se mencionó un número entero; viene de https://unix.stackexchange.com/questions/151654/checking-if-an-input-number-is-an-integer
if ! [[ "$1" =~ ^[0-9]+$ ]]; then
echo "ERROR: Un número entero es necesario para el número de páginas a escanear."
exit
fi
# Escaner con xsane
echo "Iniciando escaneando en nueva carpeta llamada «$directorio_padre»..."
mkdir $directorio_padre && cd $directorio_padre
mkdir originales && cd originales
echo "Escaneando portada a color..."
scanimage -d $impresora -v -p --resolution $dpi --format tiff > out0.tif
echo "Escaneando interiores en grises..."
scanimage -d $impresora -v -p --resolution $dpi --format tiff --mode Gray --batch --batch-start=1 --batch-count=$1
# Cambio de nombres con perl-rename
echo "Cambiando nombres de los archivos..."
perl-rename -v "s/out(\d\d\.tif)/p_0\1/" *.tif
perl-rename -v "s/out(\d\.tif)/p_00\1/" *.tif
# Postprocesamiento con Scan Tailor
cd ..
scantailor-cli -v --orientation=$orientacion --layout=$plantilla --deskew=auto --content-detection=$contenido --margins=$margenes --alignment-vertical=$alineacion_vertical --alignment-horizontal=$alineacion_horizontal --output-dpi=$dpi -o=$SCRIPT_PATH/$directorio_padre/$nombre_proyecto.ScanTailor $SCRIPT_PATH/$directorio_padre/originales $SCRIPT_PATH/$directorio_padre/scan-tailor
The Scan Tailor command in this script is: scantailor-cli -v --orientation=left --layout=2 --deskew=auto --content-detection=normal --margins=10 --alignment-vertical=center --alignment-horizontal=center --output-dpi=150 -o=path/to/proyecto.ScanTailor path/to/originales path/to/scan-tailor.
Is it possible to execute all the workflow with the cli interface?
I just had the same problem. As far as I understand the logic, this is currently (version 0.9.12.2-1, Arch community repo) a bug in the program (I now filed it here).
These are the steps called "filters":
Fix Orientation
Split Pages
Deskew
Select Content
Margins
Output
The default range claims to be 4..6 according to scantailor-cli -h but it really is 1..4 what you can see via -v. Hence you need to set --start-filter=4 --end-filter=6.
I'm looking to get computers names from my network, so i decided to use this following script :
for /L %%N in (1,1,10) do nslookup 132.147.160.%%N
PAUSE
With this command everything is displaying correctly on the command prompt.
But with this last one not so well :
for /L %%N in (1,1,256) do nslookup 132.147.160.%%N >nslookup.txt
PAUSE
First of all, the command prompt is displaying wrong things (there's a non-desired "1" added and i don't know why):
C:\Users\Toshiba\Desktop>nslookup 132.147.160.1 1>nslookup.txt
C:\Users\Toshiba\Desktop>nslookup 132.147.160.2 1>nslookup.txt
*** serveur1.mycompany.fr ne parvient pas à trouver 132.147.160.2 : Non-exi
stent domain
C:\Users\Toshiba\Desktop>nslookup 132.147.160.3 1>nslookup.txt
*** serveur1.mycompany.fr ne parvient pas à trouver 132.147.160.3 : Non-exi
stent domain
C:\Users\Toshiba\Desktop>nslookup 132.147.160.4 1>nslookup.txt
*** serveur1.mycompany.fr ne parvient pas à trouver 132.147.160.4 : Non-exi
stent domain
[ ... etc]
And also in nslookup.txt
i've got NO MORE THAN this output :
Serveur : serveur1.mycompany.fr
Address: 132.147.160.1
Nom : 132.147.160.256
Address: 60.200.60.100
Please, what am i doing wrong ?
Thank you
try this:
#ECHO OFF &SETLOCAL
for /L %%N in (1,1,10) do nslookup 132.147.160.%%N >>nslookup.txt 2>&1
TYPE nslookup.txt
To remove the error messages from nslookup.txt, simply delete 2>&1.
i need , some help , with my mini-script , to Fix , Spanish Filename with ISO_8859-1 and/or with part of names like "ó"
The Script its there : http://www.pastebin.com/vT5Z2BqE
Yesterday with a 3 Things , are working , i add more , and dont work anymore , i dont understand why .
Look , if i use that command in a "Bash Shell" / "Gnome-Terminal" like :
inukaze#Inukaze:~$ cd Filenames_to_fix
inukaze#Inukaze:~/Filenames_to_fix$
inukaze#Inukaze:~/Filenames_to_fix$ expresion='°'
inukaze#Inukaze:~/Filenames_to_fix$ sustituto='°'
inukaze#Inukaze:~/Filenames_to_fix$ ls *$expresion*
01 - La Espada del Augurio °.avi
inukaze#Inukaze:~/Filenames_to_fix$ for i in $( ls $expresion ); do
> orig=$i
> dest=$(echo $i | sed -e "s/$expresion/$sustituto/")
> mv $orig $dest
> done
mv: no se puede efectuar stat' sobre «01»: No existe el fichero o el directorio
mv: no se puede efectuarstat' sobre «-»: No existe el fichero o el directorio
mv: no se puede efectuar stat' sobre «La»: No existe el fichero o el directorio
mv: no se puede efectuarstat' sobre «Espada»: No existe el fichero o el directorio
mv: no se puede efectuar stat' sobre «del»: No existe el fichero o el directorio
mv: no se puede efectuarstat' sobre «Augurio»: No existe el fichero o el directorio
mv: no se puede efectuar `stat' sobre «°»: No existe el fichero o el directorio
I need , the change of part of filename "°" for "ª" , for example
Someone / somebody , can explain why this error , and how to fix it ???
I dont wanna interactive mode , and dont wanna replace "extension" i wanna "rename" the bad part of filename , with the "Good" character in its place :D.
Thank you for readme , and sorry my bad english , thank you for any help can you give me with this script
You do not quote $orig and $dest and that causes problems when the filename contains spaces (mv is given the file name as several separate arguments (which is why it prints several error messages with parts of the file name)). Try to use
mv "$orig" "$dest"
instead.
The for loop uses whitespace as a delimiter. Since your file name contains whitespace, you will need to change what you are using as a delimiter.
Here is the equivalent using find and while
find . -maxdepth 1 -name "*${expresion}*" -print0 | while read -d $'\0' file
do
orig="$file"
dest=$(echo "$file" | sed -e "s/${expresion}/${sustituto}/")
mv "$orig" "$dest"
done
HOWEVER, a better solution is probably to use the rename command:
rename $expresion $sustituto *${expresion}*
Is the rename command available?
rename $expresion $sustituto *$expresion*