Go to advanced search

by doubleudee1
Fri Apr 12, 2019 12:04 pm
Forum: Beginners
Topic: How to run an executable file from CRON?
Replies: 5
Views: 92

Re: How to run an executable file from CRON?

Thanks all
Thats cleared it up for me.

WD
by doubleudee1
Fri Apr 12, 2019 10:19 am
Forum: Beginners
Topic: How to run an executable file from CRON?
Replies: 5
Views: 92

How to run an executable file from CRON?

I have a couple of executable files in different directories that I would like to run at a set time, I have already got a cron file which I have a couple of commands I run in the mornings but how do I run an executable at a set time within the same cron file? e.g. my executable is in /dir1/dir2/dir3...
by doubleudee1
Thu Apr 11, 2019 11:03 am
Forum: Other programming languages
Topic: nested 'if' statements in a shell script?
Replies: 6
Views: 164

Re: nested 'if' statements?

http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-6.html else: is not else So I have to have one 'if' ....... 'fi' statement for every change I want to make? I only used the elif as I thought I could nest all changes in one 'if' ...... 'fi' statement, or is there an alternataive statement I should be usi...
by doubleudee1
Thu Apr 11, 2019 10:48 am
Forum: Other programming languages
Topic: nested 'if' statements in a shell script?
Replies: 6
Views: 164

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: 266

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: 266

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: 266

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: 266

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: 413

Re: Reading Filenames into an array

I see the same! [email protected]:~ $ FRED=/home/pi *.jpg -bash: *.jpg: command not found [email protected]:~ $ 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: 413

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: 413

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: 413

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: 413

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: 413

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: 413

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: 287

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: 287

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: 287

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: 287

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: 287

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: 287

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: 397

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: 397

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: 397

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: 397

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

Go to advanced search