Go to advanced search

by doubleudee1
Thu Apr 11, 2019 10:48 am
Forum: Other programming languages
Topic: nested 'if' statements in a shell script?
Replies: 6
Views: 869

nested 'if' statements in a shell script?

I want to move some files from one directory to another, I have the names of the diectories in variables, but initally I am testing it with the code below but am getting the errors show. How is nesting achived so i can run a statement such as below (the loop to change files & directories is not show...
by doubleudee1
Thu Apr 04, 2019 1:44 pm
Forum: Other programming languages
Topic: Another exe - mkdir question?
Replies: 6
Views: 761

Re: Another exe - mkdir question?

Thanks, but what I am looking to achieve is to create new directories inside the existing "/CCTV/RearOfHouse/" which would be named "201902", … When you say "/CCTV/RearOfHouse/", that means "CCTV off the root directory", not "CCTV relative to /home/pi". Start by creating a variable that is the abso...
by doubleudee1
Thu Apr 04, 2019 10:55 am
Forum: Other programming languages
Topic: Another exe - mkdir question?
Replies: 6
Views: 761

Re: Another exe - mkdir question?

mkdir -p is your friend: -p, --parents no error if existing, make parent directories as needed Thanks, I have '-p' in my code, so does this mean I have to move my executable file into the 'CCTV/RearOfHouse/' directory to run it? as it creates the directory (and sub dirs) inside my 'ExecFiles' dir b...
by doubleudee1
Wed Apr 03, 2019 3:47 pm
Forum: Other programming languages
Topic: Another exe - mkdir question?
Replies: 6
Views: 761

Re: Another exe - mkdir question?

mkdir -p is your friend: -p, --parents no error if existing, make parent directories as needed Thanks, I have '-p' in my code, so does this mean I have to move my executable file into the 'CCTV/RearOfHouse/' directory to run it? as it creates the directory (and sub dirs) inside my 'ExecFiles' dir b...
by doubleudee1
Wed Apr 03, 2019 1:35 pm
Forum: Other programming languages
Topic: Another exe - mkdir question?
Replies: 6
Views: 761

Another exe - mkdir question?

I have a directory where I am keeping all my executable files it is is /home/pi/ExecFiles, I am the only user of my pi so I thought it would be OK to create and run any exec files I want from there. I have created one as shown below:- ###/home/pi/CCTV/RearOfHouse/ARC2019042134139.jpg = full path inc...
by doubleudee1
Thu Mar 21, 2019 5:13 pm
Forum: Other programming languages
Topic: Reading Filenames into an array
Replies: 14
Views: 1032

Re: Reading Filenames into an array

I see the same! pi@RPi3BplusOffice:~ $ FRED=/home/pi *.jpg -bash: *.jpg: command not found pi@RPi3BplusOffice:~ $ What do you hope to achieve by the "*.jpg" part of that command - it looks superfluous, as proven by the possibility correct output that follows? Sorry, I added the .jpg thinking it wou...
by doubleudee1
Thu Mar 21, 2019 3:51 pm
Forum: Other programming languages
Topic: Reading Filenames into an array
Replies: 14
Views: 1032

Re: Reading Filenames into an array

No space! ./filename The script may need to be made executable first: chmod +x filename Thanks, space taken out and file made executable, output now as expected: (except it doesn't like me declaring the type of file to look for)- ./CreateSecurityDirs: line 4: *.jpg: command not found /*.jpg /*.mp4 ...
by doubleudee1
Thu Mar 21, 2019 3:29 pm
Forum: Other programming languages
Topic: Reading Filenames into an array
Replies: 14
Views: 1032

Re: Reading Filenames into an array

B.Goode wrote:
Thu Mar 21, 2019 3:10 pm
The only error I get when running the code is:-

-bash: ./: Is a directory
What do you type at the shell (command line) prompt to run your shell script?
I put in :-

./ filename

from the same directory the file I created (above) exists in and then press enter
by doubleudee1
Thu Mar 21, 2019 2:59 pm
Forum: Other programming languages
Topic: Reading Filenames into an array
Replies: 14
Views: 1032

Re: Reading Filenames into an array

sorry, same result using your suggested code I didn't suggest any code... If you have an error, share the code and the full text of any resulting error message. ###########################=============================################## ###########################CODE1 #!/bin/bash SOURCE_DIR=/home/p...
by doubleudee1
Thu Mar 21, 2019 2:30 pm
Forum: Other programming languages
Topic: Reading Filenames into an array
Replies: 14
Views: 1032

Re: Reading Filenames into an array

As an overall approach, as with conventional programming languages, lots of intermediate snapshots of the state of your variables might help? I think that in the bash shell the echo command might be the tool to use. But, unverified, here is something to check out - You have SOURCE_DIR=/home/pi/CCTV...
by doubleudee1
Thu Mar 21, 2019 12:44 pm
Forum: Other programming languages
Topic: Reading Filenames into an array
Replies: 14
Views: 1032

Re: Reading Filenames into an array

topguy wrote:
Thu Mar 21, 2019 12:33 pm
And the error doesnt report any specific line number ?

Do the error go away if you remove:

Code: Select all

"$SOURCE_DIR"/**/*
No, I've tried commening out that line and I still get the same error?
by doubleudee1
Thu Mar 21, 2019 12:23 pm
Forum: Other programming languages
Topic: Reading Filenames into an array
Replies: 14
Views: 1032

Reading Filenames into an array

I have this script from a site that i thought would work, that I altered to suit, but I am getting an error '-bash: ./: Is a directory' #!/bin/bash SOURCE_DIR=/home/pi/CCTV/RearOfHouse/TestDirs/ files=( "$SOURCE_DIR"/*.jpg "$SOURCE_DIR"/*.mp4 "$SOURCE_DIR"/**/* ) printf '%s\n' "${files[@]}" # i.e. p...
by doubleudee1
Sun Mar 17, 2019 3:21 pm
Forum: Beginners
Topic: ARC20190311150800.mp4
Replies: 8
Views: 682

Re: ARC20190311150800.mp4

Thanks for your help and guidance.
WD
by doubleudee1
Sun Mar 17, 2019 11:50 am
Forum: Beginners
Topic: ARC20190311150800.mp4
Replies: 8
Views: 682

Re: ARC20190311150800.mp4

Firstly, you are supposed to put all of those commands into a file and make it executable, then run it from the command prompt. Secondly, there is a big difference between $(file:3:4) and ${file:3:4} Sorry, my eyesight is going so I mistook curly brackets for straight ones. I will look up how to pu...
by doubleudee1
Sun Mar 17, 2019 11:23 am
Forum: Beginners
Topic: ARC20190311150800.mp4
Replies: 8
Views: 682

Re: ARC20190311150800.mp4

Something like this will create the directory in the format YYYYMM (not tested on a Pi - only Pi Desktop emulated under Fusion): year=${file:3:4} month=${file:7:2} filedate=${year}${month} mkdir -p ${filedate} This will return the current date in YYYYMM (I have assumed you are using the UK locale f...
by doubleudee1
Sun Mar 17, 2019 9:45 am
Forum: Beginners
Topic: ARC20190311150800.mp4
Replies: 8
Views: 682

Re: ARC20190311150800.mp4

Something like this will create the directory in the format YYYYMM (not tested on a Pi - only Pi Desktop emulated under Fusion): year=${file:3:4} month=${file:7:2} filedate=${year}${month} mkdir -p ${filedate} This will return the current date in YYYYMM (I have assumed you are using the UK locale f...
by doubleudee1
Sat Mar 16, 2019 5:38 pm
Forum: Beginners
Topic: ARC20190311150800.mp4
Replies: 8
Views: 682

Re: ARC20190311150800.mp4

Something like this will create the directory in the format YYYYMM (not tested on a Pi - only Pi Desktop emulated under Fusion): year=${file:3:4} month=${file:7:2} filedate=${year}${month} mkdir -p ${filedate} This will return the current date in YYYYMM (I have assumed you are using the UK locale f...
by doubleudee1
Sat Mar 16, 2019 12:43 pm
Forum: Beginners
Topic: ARC20190311150800.mp4
Replies: 8
Views: 682

ARC20190311150800.mp4

I have set up a NAS to which I send files (both .mp4 and .jpg) from my security cameras. Currently I move the ;.jpg' files from the main directory to another directory called 'jpgFiles', if the files are older than 7 days, but the search for these files is taking longer and longer each day it runs a...
by doubleudee1
Thu Mar 14, 2019 10:27 am
Forum: Beginners
Topic: Listing the command lines that I have written
Replies: 12
Views: 549

Re: Listing the command lines that I have written

Thanks all.

WD
by doubleudee1
Thu Mar 14, 2019 10:10 am
Forum: Beginners
Topic: Listing the command lines that I have written
Replies: 12
Views: 549

Re: Listing the command lines that I have written

You can edit the line when it is on screen using the left/right cursor keys and delete etc. You can highlight the text in a terminal window then copy with shift ctrl c and paste with shift ctrl v. Ah! so i can just alter it on the screen and then re-run it and it will overwrite the initial command?
by doubleudee1
Thu Mar 14, 2019 9:33 am
Forum: Beginners
Topic: Listing the command lines that I have written
Replies: 12
Views: 549

Re: Listing the command lines that I have written

Thanks all, I'm getting there (slowly) :D
Is there a way of altering a pice of code I have entered into the shell window? Or a way of deleting it and then entering a new updated piece?
by doubleudee1
Thu Mar 14, 2019 9:03 am
Forum: Beginners
Topic: Listing the command lines that I have written
Replies: 12
Views: 549

Listing the command lines that I have written

Hi
I've set up several lines of code to do different things on my PI. e.g. move files that are older than 7 days from one folder to another.

How can I list all that I have written ?
and can I alter them ?
or will I have to re-write them over again?


Thanks
by doubleudee1
Tue Feb 12, 2019 1:51 pm
Forum: Beginners
Topic: web link query?
Replies: 3
Views: 104

Re: web link query?

You may do better asking on the forum of the camera maker rather than here but my guess is that the camera software is designed only to allow ftp access from addresses on the local LAN and not remotely. This is designed to stop bots trying to download ‘incriminating’ videos or to take over the came...
by doubleudee1
Tue Feb 12, 2019 12:43 pm
Forum: Beginners
Topic: web link query?
Replies: 3
Views: 104

web link query?

when I log in to my pi from an external source it takes me to the webpage at:- /var/www/html/index.php Which opens fine and shows me all the text I have there plus the link below. Now on this web page i have put a link :- ftp:my-pi's-internal-address/CCTV If I open the web page intenally (from my lo...
by doubleudee1
Fri Feb 08, 2019 11:19 am
Forum: Beginners
Topic: how to delete accidently named files?
Replies: 5
Views: 421

Re: how to delete accidently named files?

Thanks didn't know I could use " " around filename

Go to advanced search