Cannot access saved file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Cannot access saved file
# 1  
Old 08-05-2018
Cannot access saved file

This may be wrong place to ask.

I am currently modifying "stock" configuration file and making slow progress.

Run into a snag - twice so far.

I can work on the project switching from editing to run all day long, no issue.

Next day i cannot access the file to run it.

The file is still there ( ls...) and to my knowledge still accessible as far as security.



Here is a snippet of terminal output

Code:
....

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Sun Aug  5 15:03:19 2018 from 10.0.1.41
pi@pi:~ $ cd /usr/bin 
pi@pi:/usr/bin $ sudo raspi-config.test

there is no output / reaction after last line and the solution is to exit from terminal.
and stat over.

I am using "remote" ssh to access the file, but I get same behavior when executed locally.


I have no problems editing the file



Code:
pi@pi:/usr/bin $ sudo nano raspi-config.test


just cannot run it after next save.


Any help would be appreciated, but if it is wrong to post here , my apology.

Moderator's Comments:
Mod Comment Please use code tags for all code and data snippets.
# 2  
Old 08-05-2018
Try changing file permissions on the file you want to write to. Then put it in YOUR home directory
Code:
pi@pi:/usr/bin $ sudo mv raspi-config.test /home/pi  # move to pi's directory
cd   # go to home directory
pi@pi /usr/bin/sudo chown pi raspi-config.test
pi@pi chmod 755 raspi-config.test
# you now own the file and it is in your home directory
# edit the file:
pi@pi: nano raspi-config.test
# if you like the changes copy it back
/usr/bin/sudo cp /home/pi/raspi-config.test /usr/bin/raspi-config.test
# you are running now as the user pi, you only need sudo to cp the file

What this does: basically make a local copy you can play with safely, and without advanced permissions

Not a the best way is to su to root:
Code:
pi@pi: sudo su - root
password [enter your pi user password]
# you are now root, you can generally delete/write/modify permissions on  any file in anywhere .... be careful

If you forget you are root you can destroy the whole system with one command. Be careful.
Now you do not need to sudo or anything else except edit the file and do whatever config changes you want.

Last edited by jim mcnamara; 08-05-2018 at 01:31 PM..
# 3  
Old 08-05-2018
You may be confusing 'saving' a file with 'closing' a file.

If you save the file in your editor, the editor doesn't know that you've finished and could have the file still locked. If you close the file then you let go of it.
# 4  
Old 08-05-2018
Show your code.

Tell us what you are attempting to do.

Right now we know neither.
# 5  
Old 08-05-2018
I am using Ctrl X to " Exit " and then save the file in nano editor.

Works OK until I restart my system next day.



Perhaps i need to use Ctrl O "Write out"



As far as changing file location - I just "copy /edited" in /usr/bin where the original is.

It is a good idea since I am very dangerous at this point.



i did checked another copy - with same problem and this is what I got


Code:
pi@pi:/usr/bin $ ls -l raspi-config.copy
-rw-r--r-- 1 root root 53398 Aug  5 16:23 raspi-config.copy


Should I see "x" there ?

------ Post updated at 01:06 PM ------

Well moving the file did not exactly work
I can list it - ls , edit it , but still no run.



Here is my output , it is title redundant and messy , but I am posting it here in case I did something obviously stupid.





Code:
pi@pi:~ $  pi@pi:/usr/bin $ sudo mv raspi-config.test /home/pi  # move to pi's directory
-bash: pi@pi:/usr/bin: No such file or directory
pi@pi:~ $ # you are running now as the user pi, you only need sudo to cp the filepi@pi:~ $ pi@pi:/usr/bin $ sudo mv raspi-config.test /home/pi  # move to pi's directory
pi@pi:~ $ cd /usr/bin
pi@pi:/usr/bin $ sudo mv raspi-config.test /home/pi  # move to pi's directory
pi@pi:/usr/bin $ cd 
pi@pi:~ $ /usr/bin/sudo chown pi raspi-config.test
pi@pi:~ $ nano raspi_config.test
pi@pi:~ $ ls
Desktop    oldconffiles           python_games       wpa_supplicant
Documents  org.eclipse.tcf.agent  raspi-config.test
Downloads  Pictures               Templates
Music      Public                 Videos
pi@pi:~ $ nano raspi-config.test  editing works 
pi@pi:~ $ raspi-config.test
-bash: raspi-config.test: command not found
pi@pi:~ $ sudo raspi-config.test
sudo: raspi-config.test: command not found
pi@pi:~ $ chmod +x raspi-config.test
pi@pi:~ $ raspi-config.test
-bash: raspi-config.test: command not found
pi@pi:~ $ sudo raspi-config.test
sudo: raspi-config.test: command not found
pi@pi:~ $


I need a break, so Ill wont immediately respond.

Appreciate all the help.





PS I got reprimand for not posting code in tags.

SO I try to copy tagged post but could not figure it out.

Did the normal "cut and paste" using mouse.

SO is there a trick to "copy tagged code "?

------ Post updated at 01:16 PM ------

Quote:
Originally Posted by Corona688
Show your code.

Tell us what you are attempting to do.

Right now we know neither.

What's with "us" and "we" ?

Apparently it is you who needs the info I already shared in my posts.



I am getting good help I need now without "what and why" details.

Hope it will continue.



Can you add anything constructive to the discussion without getting the info you asked for ?

Last edited by RudiC; 08-05-2018 at 04:07 PM..
# 6  
Old 08-05-2018
Calm down, please.

I'm not sure it'd be wise to upset the forum moderators' crew in your fifth post if you want to continue "getting good help" in these fora.

Quote:
Originally Posted by annacreek
. . .
What's with "us" and "we" ?
"We" and "us" are the forum members in general, and the suppliers of advice in particular, last but not least the advisors and moderators running these fora.

Quote:
Can you add anything constructive to the discussion without getting the info you asked for ?
Again, calm down. I have a guess or two what could be wrong in your setup. Had the info requested by Corona688 been available from the beginning, had you given the entire picture, you might already have gotten a solution to your problem.

Quote:
PS I got reprimand for not posting code in tags.

SO I try to copy tagged post but could not figure it out.

Did the normal "cut and paste" using mouse.

SO is there a trick to "copy tagged code "?
Now, this is mentioned in several places, e.g. JUST ABOVE the editor, or in the forum rules and FAQs. Select the code or data section in your post, and click the code button on top of the editor. Repeat for every section if needed.

Last edited by RudiC; 08-05-2018 at 04:10 PM..
# 7  
Old 08-05-2018
Here is a quick tutorial on how to use CODE tags...

This User Gave Thanks to Don Cragun For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Squares in saved code

can you help i am merging 2 files together and saving to a third file with awk and its working with this code awk 'OFS="";NR==FNR{a=$0;next} {print a,"\n","\b",$0}' file1 file2 > file3the problem is in file3 when its saved i get a small square at the start of every 2nd line (see picture) ... (6 Replies)
Discussion started by: bob123
6 Replies

2. UNIX for Dummies Questions & Answers

Script Not getting Saved

Hi , Script File Is Not Getting Saved This Are The Steps I Am Following For Saving And Executing A Script 1). vi ( To Open Vi Editor ) 2). vi filename ( vi firstprog.ksh) #!bin\kash date 3) !wq :( Saving And Quit) When I Am Saving The Scrpit I Am Getting The Below... (1 Reply)
Discussion started by: anudeepkumar123
1 Replies

3. Shell Programming and Scripting

Script to open a saved file and modify the content

I am looking for a script where I need to open a file and modify the data like changing the parameters.Can anyone help me? open a file software.rsp . It already contains following data. parameter = false threads=100 user= demf The above should be changed to paramter=true thread= 133... (3 Replies)
Discussion started by: sriki32
3 Replies

4. UNIX for Dummies Questions & Answers

where alias saved?

step 1 # alias alias cp='cp -i' alias l.='ls -d .* --color=tty' alias ll='ls -l --color=tty' alias ls='ls --color=tty' alias mv='mv -i' alias rm='rm -i' alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde' step 2 # cat ~/.bashrc # .bashrc (3 Replies)
Discussion started by: cqlouis
3 Replies

5. UNIX and Linux Applications

Bluefish: where are the preferences saved?

I have just tried out Bluefish as an alternative to my regular text editor. If I save the modified preferences and reboot, the preferences have to be reentered again. Does anyone know which file the preferences are saved in? The command find / -mmin -5 | grep bluefish yields zero hits. Thanks... (2 Replies)
Discussion started by: figaro
2 Replies

6. Shell Programming and Scripting

Can STDERR be saved to a variable

Guys i'm trying to save STDERR to a variable for a portion of my ksh script on solaris. I know i can create redirects to files as such: exec 4>/tmp/lava print "This will be saved to /tmp/lava and not screen"; >&4 print "This will be seen on screen" >&2 I want to save the STDOUT of a... (4 Replies)
Discussion started by: lavascript
4 Replies

7. Shell Programming and Scripting

How can I identify the last saved log?

Our system produce logs when a script is run which may not be daily, the logs have a format: name_YYMMDD.log - both name and .log are consistent, date changes as per the day the script is run. Is there a way of finding the last saved log? (20 Replies)
Discussion started by: gugs
20 Replies

8. UNIX for Advanced & Expert Users

Sudo file not saved

Hi all, I have edited my sudoers file. I am using visudo command I have added the following lines and saved the file. I am saving the lines as :wq But I am very amazed to see that these lines are not written in the sudoers file. I have retried the above process many times, when I... (0 Replies)
Discussion started by: Asteroid
0 Replies

9. UNIX for Advanced & Expert Users

only root's crontab gets not saved

Hi, Something funny is happening over here: when a regular user edits his cron-file (crontab -e) saves and exits vi the correct new cron-file gets installed and saved to disk. But if root does the same, vi saves it but if I then check the cron-file it has the previous contents! I did strace (==... (1 Reply)
Discussion started by: flok
1 Replies
Login or Register to Ask a Question