I'm trying to pipe the output of a "git pull" command to both a file and stdout using the following script:
STD_OUT=`mktemp`
git pull | $STD_OUT
rm -f $STD_OUT
This results in:
./test.sh: line 2: /tmp/tmp.BITQRbsMSI: Permission denied
error: git-pull died of signal 13
Why am I denied permission to the temp file I just created and what's the alternative?
"Piping to a file" is not a legal operation in bash (or any other shell). The thing following a | has to be a command. If you want to redirect the output from the git operation into the file, use the redirect operator >:
git pull > $STD_OUT
Related
When running below command directly in bash shell, I am able to get the output. But when I am passing it via BASH script getting access denied. Any help would be appreciated
$ jq -r '.id' Repooutput.txt
dad04f6d-4e06-4420-b0bc-cb2dcfee2dcf
Error:
$ sh test.sh
test.sh: line 3: /c/ProgramData/chocolatey/bin/jq: Permission denied
I think the reason is that when executing the script with sh test.sh we're asking the POSIX interpreter (shell) to execute the content on the script, while when executing it with ./test.sh we're asking the script to "execute itself".
For the latter, the file needs to have execution permissions, which you can add with
chmod +x test.sh
Issue was with the naming convention of JQ inside BASH folder path, because of which the script was unable to pick the command. Renaming the JQ within BASH folder resolved this
When i am typing
git add *.c
the error shown is
warning: could not open directory 'AppData/Local/Application Data/':
Permission denied
warning: could not open directory 'AppData/Local/ElevatedDiagnostics/': Permission denied
warning: could not open directory 'AppData/Local/History/': Permission denied
warning: could not open directory 'AppData/Local/Microsoft/Windows/INetCache/Content.IE5/': Permission d enied
warning: could not open directory 'AppData/Local/Microsoft/Windows/INetCache/Low/Content.IE5/': Permissi on denied
warning: could not open directory 'AppData/Local/Microsoft/Windows/Temporary Internet Files/': Permissio n denied
warning: could not open directory 'AppData/Local/Temporary Internet Files/': Permission denied
warning: could not open directory 'Application Data/': Permission denied
warning: could not open directory 'Cookies/': Permission denied
warning: could not open directory 'Documents/My Music/': Permission denied
warning: could not open directory 'Documents/My Pictures/': Permission denied
warning: could not open directory 'Documents/My Videos/': Permission denied
0 [sig] bash 22680! sigpacket::process: Suppressing signal 18 to win32 process (pid 23616)
warning: could not open directory 'Local Settings/': Permission denied
warning: could not open directory 'My Documents/': Permission denied
warning: could not open directory 'NetHood/': Permission denied
warning: could not open directory 'PrintHood/': Permission denied
warning: could not open directory 'Recent/': Permission denied
warning: could not open directory 'SendTo/': Permission denied
warning: could not open directory 'Start Menu/': Permission denied
warning: could not open directory 'Templates/': Permission denied
warning: LF will be replaced by CRLF in .atom/packages/script/examples/colored_diagnostics.c.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in .atom/packages/script/examples/hello.c.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in .atom/recovery/stringdel-c5a98d.c.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in AppData/Local/Programs/Python/Python36-32/Lib/site-packages/nump y/distutils/mingw/gfortran_vs2003_hack.c.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in AppData/Local/Programs/Python/Python36-32/Lib/site-packages/nump y/f2py/src/fortranobject.c.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in AppData/Local/Programs/Python/Python36-32/Lib/site-packages/nump y/f2py/tests/src/array_from_pyobj/wrapmodule.c.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in AppData/Local/atom/app-1.27.0/resources/app/apm/node_modules/npm /node_modules/request/node_modules/node-uuid/benchmark/benchmark-native.c.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in AppData/Local/atom/app-1.27.1/resources/app/apm/node_modules/npm /node_modules/request/node_modules/node-uuid/benchmark/benchmark-native.c.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in AppData/Local/atom/app-1.27.2/resources/app/apm/node_modules/npm /node_modules/request/node_modules/node-uuid/benchmark/benchmark-native.c.
The file will have its original line endings in your working directory.
1241365 [sig] bash 22680! sigpacket::process: Suppressing signal 18 to win32 process (pid 23616)
2219951 [sig] bash 22680! sigpacket::process: Suppressing signal 18 to win32 process (pid 23616)
2611925 [sig] bash 22680! sigpacket::process: Suppressing signal 18 to win32 process (pid 23616)
2758249 [sig] bash 22680! sigpacket::process: Suppressing signal 18 to win32 process (pid 23616)
2990144 [sig] bash 22680! sigpacket::process: Suppressing signal 18 to win32 process (pid 23616)
3176253 [sig] bash 22680! sigpacket::process: Suppressing signal 18 to win32 process (pid 23616)
3360807 [sig] bash 22680! sigpacket::process: Suppressing signal 18 to win32 process (pid 23616)
3523597 [sig] bash 22680! sigpacket::process: Suppressing signal 18 to win32 process (pid 23616)
3746325 [sig] bash 22680! sigpacket::process: Suppressing signal 18 to win32 process (pid 23616)
3964192 [sig] bash 22680! sigpacket::process: Suppressing signal 18 to win32 process (pid 23616)
4150814 [sig] bash 22680! sigpacket::process: Suppressing signal 18 to win32 process (pid 23616)
4335693 [sig] bash 22680! sigpacket::process: Suppressing signal 18 to win32 process (pid 23616)
warning: LF will be replaced by CRLF in Desktop/exploringBB-master/chp03/HelloWorldSleep.c.
....
Please help me. I do not know what to do just to add a file. My repository folder has some files that do not have permission. How do I change these permissions or should I change my repository folder>
I'm currently working under windows.
Seems like you are trying to perform git operations inside your user directory.
C:\Users\{user-name}
Please make sure your git bash or cmd points to correct folder.
I had the same issue and by navigating to correct folder it worked fine for me
As a suggestion use cd foldername then again cd foldername to navigate
You just need to delete log files.
Use the command
rm -rf .git
It will solve your problem. Before entering this command remember one thing that it will clear all your log files and delete .git folder.
in my case, I solved this error by running the following commands:
git init
git add -A
git Commit -a -m "your message"
Be sure u are in the correct path(folder)
then use :
git init
git status
Just change your directory where the actual files are located then list them (ls -l). You will find your file there. once you done this your command will work fine git add <filename>.
What I did is:
sarat#DESKTOP-9BPO08D MINGW64 /d
$ cd files1
sarat#DESKTOP-9BPO08D MINGW64 /d/files1
$ git init
Initialized empty Git repository in D:/files1/.git/
sarat#DESKTOP-9BPO08D MINGW64 /d/files1 (master)
$ ls -l
total 1
-rw-r--r-- 1 sarat 197609 396 May 25 21:15 Camera_Follow.cs
sarat#DESKTOP-9BPO08D MINGW64 /d/files1 (master)
$ git add Camera_Follow.cs
sarat#DESKTOP-9BPO08D MINGW64 /d/files1 (master)
$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: Camera_Follow.cs
Seems like you didn't initialised git on you folder,
Start by:
git init
git status
git add -A
it will work
I successfully use the python tool tqdm to display a nice progress bar for e.g. unzipping a large file. However I don't know how to stop that and showing errors from the unzip command if any.
#!/bin/bash
function progressBarFiles() {
local total_files="$1"
if hash tqdm 2>/dev/null; then
tqdm --total $total_files --unit files --desc counting | wc -l >/dev/null
else
cat
fi
}
unzip -o huge.zip | progressBarFiles 1697
Currently I have the case of unzipping in a network folder fails due to file permission changes failing:
counting: 1%|█▉ | 22/1697 [00:00<00:28, 58.36files/s]
chmod (directory attributes) error: Permission denied
chmod (directory attributes) error: Permission denied
chmod (directory attributes) error: Permission denied
counting: 2%|██▎ | 26/1697 [00:00<00:35, 46.64files/s]
chmod (directory attributes) error: Permission denied
I would like to stop the script after the progress bar and print this error output all together instead of at the moment in unzipping (which breaks the progress bar).
PS: Is the idea with cat to have that progress bar completely optional improvable?
Solved this as stated in the comment with redirecting, but with a clean temporary file that will be deleted 100%, see https://stackoverflow.com/a/51137057/1184842 for more details.
I have the following script:
https://gist.github.com/pc-magas/37ec5e668c12017eb32aa308a0cb8f35
And on the execution I have these error messages:
./scripts/install2.sh: line 84: /home/pcmagas/Kwdikas/Docker/ellakcy/scripts/../start.sh: Permission denied
./scripts/install2.sh: line 87: /home/pcmagas/Kwdikas/Docker/ellakcy/scripts/../stop.sh: Permission denied
./scripts/install2.sh: line 89: ${STARTUP_SCRIPT_PATH}: ambiguous redirect
chmod: missing operand after 'u+x'
Try 'chmod --help' for more information.
Startup script generated
./scripts/install2.sh: line 94: ${STOP_SCRIPT_PATH}: ambiguous redirect
chmod: missing operand after 'u+x'
Try 'chmod --help' for more information.
The source of the errors are these lines of script:
touch "${SCRIPT_PATH}/start.sh"
STARTUP_SCRIPT_PATH= "${SCRIPT_PATH}/start.sh"
touch "${SCRIPT_PATH}/stop.sh"
STOP_SCRIPT_PATH= "${SCRIPT_PATH}/stop.sh"
What I want/try to do is my script by given some parameters to auto-generate scripts in order to start and stop some docker container services.
But somehow the plan backfires to me right now.
May I have some help please.
You need sudo to get permission to write the script files, and there were spaces between the variable name and value; there must not be any spaces around the = signs:
sudo touch "${SCRIPT_PATH}/start.sh"
STARTUP_SCRIPT_PATH="${SCRIPT_PATH}/start.sh" # Note no spaces ..PATH="${..
sudo touch "${SCRIPT_PATH}/stop.sh"
STOP_SCRIPT_PATH="${SCRIPT_PATH}/stop.sh" # Again here.
I try to redirect output from a command in a terminal window in Max OSX (10.9.4) and get an error message. When I try this easy command:
ls > file_list.txt
I get this error:
-bash: file_list.txt: Operation not supported
Anybody an idea?
Thanks
This is the error you get if you try to create a file somewhere like /dev, which is the mount point for a special filesystem that doesn't (ordinarily) allow you to create files:
$ cd /dev
$ ls > file_list.txt
bash: file_list.txt: Permission denied
# Oops, we get permission denied before we even try to create the file.
$ sudo -s
Password:
# ls > file_list.txt
bash: file_list.txt: Operation not supported