I have a simple script to move files between directories. Basically, it is:
mv /dir/* /dir/proc/
saved into a shell script "mvproc.sh".
For some reason, when I run the script (sh mvproc.sh) the file indeed gets moved, but it does not retain the filename and instead gets just an empty filename. When I run the same command at the bash prompt, it works fine however.
This script used to work fine on Debian but we had a hard drive failure and I am now migrating everything over to a Ubuntu machine.
Any idea why this is happening? It seems so simple yet I cannot figure it out.
Many thanks.
edit...
I think I found the solution. For some reason it was putting in carriage returns and maybe line breaks or something that I could not see while editing the sh script in either Notepad++ or even gedit. To solve this, when I open the scripts in gedit, I do a Save As, and select Unix/Linux in the drop down menu towards the bottom. This hopefully gets rid of the weird carriage returns even though I could not see them.
Hopefully this helps some poor soul like me in the future pulling their hair out over this!
Thanks!
Try: mv /dir/file /dir/proc/file
You are indeed moving the file, but aren't specifying a destination name. Other usages of mv:
Move and rename: mv /dir/filename /dir/proc/newfilename
Rename: mv /dir/filename /dir/newfilename
Related
i came across a problem with subversion at my work. I want to create a post-commit-hook (post-commit.bat file) command that creates information about the last transaction.
The code looks like this:
#echo off
set file="D:\mypath\logfile%2.txt"
svn log D:\'my path to repro'\ -r %2 -v > %file%
The %2 corresponds to the last revision number. It creates the file with the correct number and tries to write in it. But then the commit hangs and the file remains open. The curious thing is, if I manually trigger the command with a valid revision number, then the whole thing works. Only with the hook it hangs and it also does not commit the files.
Can anyone help me or have any ideas for my problem?
I found a solution, maybe this might be helpful for some person.
I used the wrong command "log". Instead you have to use "svnlook changed..." on the server to get the latest information about the last commit.
I'm trying to create a fairly simple batch file to download a file from our ftp site and store it in a specific directory. I would like to be able to put the batch file in the path so I can call it from anywhere. Currently I have a line like the following:
curl -v -u %FTP_USER%:%FTP_PASS% -Q "TYPE I" -o %OUTPUT_PATH% "ftp://%FTP_HOST%/%JAR_FILE_NAME%"
What I've discovered is that no matter the value of the output path, the file is always written in the current directory, and any path seperators are converted to underscores in the file name. This happens no matter if I use a '\' or '/' and if I try to escape it with double slashes I just end up with two underscores. Quotes around things don't seem to help either.
My question is does the -o option allow for outputting to a folder other than current working dir? I guess I can have the next step in the script to be "move the file to its destination", but that seems really kludgey.
This sounds exactly like a regression (reported here) we unfortunately brought in curl 7.47.0. We hope to release an updated, fixed, version soon and in the mean time you can probably consider downgrading to an earlier version to work-around this annoying issue.
I'm trying to output my logfiles to a subfolder relative to my install script, and MSIExec doesn't seem to like it when used with the "/l*v" command. I've tried variations of %~dp0Logs (with and without quotes, etc.). If I manually enter the full path like: /l*v c:\scripts\logs\%computername%.txt" it works fine, but the script is always going to be in different locations (USB, network, etc.).
I see references online to using the %temp% system variable which I guess works, but not the parent lookup folder variable of %dp0. And I'm using the same variable elsewhere in my script for other things, like running the MSI and file copy commands (copy "%~dp0Files\Images\%LogonBackgroundWinXP%"...). I've even tried setting a variable like: Set LogFolder=%dp0\logs, but that doesn't seem to work either.
Am I missing something or am I just going to have to find another folder lookup method just for my log files?
Thanks,
Brian
I guess all I needed was a few hours away from this and lunch! Works perfectly fine, not sure what I was doing wrong before. I was going to do a copy command afterwards, but now I don't have to.
I try to run a C implementation of Sift feature descriptor executable from matlab at linux. The script I run and the executable at the some folder and executable is run by the following
./sift <tmp.pgm >tmp.key
and I trued to run it on Matlab with followings but none of them worked
eval('!./sift <tmp.pgm >tmp.key');
system('./sift <tmp.pgm >tmp.key');
unix('./sift <tmp.pgm >tmp.key');
I also check the executable from terminal and it works without any flaw. Is there any other way to do that or Do i have any slight mistake?
Your syntax looks right.
The -1 status means it's probably failing to find or launch sift at all. I know this is basic (and I think someone else mentioned it), but is your Matlab program running from the same directory that sift is in when it calls it? The system() function evaluates paths with respect to the Matlab session's current directory, not the location of the calling script. If your script has called cd for other reasons, that'll affect it. Check your current directory with pwd and do an ls and exist('./sift', 'file') to make sure it's there.
If this is the case, you could make it more robust by calling sift with an absolute path, maybe calculated at run time using fileparts(mfilename('fullpath')) in the script.
I figure out the problem as the path /matlab/bin/glnxa64/matlab_helper has permission problem. After I check the problem, everything started to work correctly.
I had the same problem of permission. Just adding solution for others to see as i had hard time finding the solution.
Open terminal and type
cd \path_of_your_file
sudo chmod -R 777
it will ask for your password and will permit to run the exe. Hugs..
I have a strange file in my file system without the extension part. The filename is "15.". The weird thing is that it is not one of those without the dot part (like just "15"), but the one with the dot but no extension ("15.") -- it is literally an illegal filename in windows, and not sure how did it get created in the first place.
I know it is a text file and it is about 15KB in size; however, due to the weirdness in name, I can't open it with any application -- I've tried to open in notepad, wordpad, etc., have tried the 'type' command to spit it out on commans shell, tried to shell-open enclosing filename in quotes, and so on -- all methods result in a 'file not found' error except the notepad, which says '15.txt' is not found.
Due to the nature of the issue and the way search engines optimize the search, it is extemely hard to search for an answer in any of the search engines online. So, I just wanted to put this question out there and see if anybody had to deal with a similar issue and have found any way to rename the file or even to change the extension.
Filenames that are valid in NTFS but cannot be used from Windows can be created when accesing disks or shares from other operating systems like Linux.
If you don't have a Linux installation at hand, then get hold of a "live" CD, boot Linux, and change the filename.
That may sound like a hassle, but Windows-only solutions (moving stuff around, deleting the directory) are even worse.
Use REN: http://ss64.com/nt/ren.html
It is a command prompt command (run > cmd > cd wherever > ren 15. 15.txt )