Sponsored Content
Top Forums UNIX for Beginners Questions & Answers How to check if a file is open in editor? Post 303005509 by Don Cragun on Wednesday 18th of October 2017 08:45:37 PM
Old 10-18-2017
Forget putting your code in a script!

What happens when you run the following commands directly in your shell:
Code:
gedit somefile& PID=$!
wait $PID

where somefile is the name of some file that you can edit? If this didn't work for you when run outside of a script, what makes you think it should work when you run it inside a script?

As I said in post #12 in this thread:
Quote:
How is it that you expect to edit a file when your editor is running in the background and can't read editing instructions from the terminal?
Jobs run in the background are blocked if they try to read from or write to their controlling terminal. The wait command that you are executing is not reporting that gedit terminated; it is reporting that gedit was stopped (probably by a SIGTTOU or SIGTTIN signal).

Maybe issuing the following command line in a shell would be instructive:
Code:
gedit somefile& PID=$!; sleep 10; jobs $PID; sleep 10; fg $PID

This User Gave Thanks to Don Cragun For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Unable to open files in VI editor

Hi, I unable to open any file using Vi editor,constantly getting the following error, vi log.log *** glibc detected *** malloc(): memory corruption: 0x081af510 ** uname -a Linux sekac092 2.6.5-7.244-bigsmp #1 SMP Mon Dec 12 18:32:25 UTC 2005 i686 athlon i386 GNU/Linux Also Note ls... (8 Replies)
Discussion started by: ennstate
8 Replies

2. Shell Programming and Scripting

How to give permissions to an open file in vi editor?

Hi all, I have a shell script that i started editing, only in the midst of which i tried to save the changes i found that the file wasnt been provided with write/execute permissions. I later have redone the changes and saved the file- Just curious to know if there was any command wherein... (5 Replies)
Discussion started by: Pankajakshan
5 Replies

3. UNIX for Advanced & Expert Users

getting error when open vi editor

helo I install my product for koren language I m uisng RHEL -4 operating system now problem is whenever I open any file vi filename I got following error on the screen E557: Cannot open termcap file 'vt100' not known. Available builtin terminals are: builtin_ansi ... (1 Reply)
Discussion started by: amitpansuria
1 Replies

4. UNIX for Dummies Questions & Answers

How to open file in VI Editor at a specific line?

i have following query e.g i want the VI Editor cursor at line number N instead of 0 while opening the file from unix prompt. vi filename ?????? Can anyone help? (4 Replies)
Discussion started by: skyineyes
4 Replies

5. Shell Programming and Scripting

avoid open file to check field.

Hi Everyone, # cat a.txt 94,aqqc,62345907, 5,aeec,77, # cat 1.pl #!/usr/bin/perl use strict; use warnings; use Date::Manip; open(my $FA, "/root/a.txt") or die "$!"; while(<$FA>) { chomp; my @tmp=split(/\,/, $_); if (index($tmp, "qq") ne -1) { ... (4 Replies)
Discussion started by: jimmy_y
4 Replies

6. Solaris

Before I delete any file in Unix, How can I check no open file handle is pointing to that file?

I know how to check if any file has a unix process using a file by looking at 'lsof <fullpath/filename>' command. I think using lsof is very expensive. Also to make it accurate we need to inlcude fullpath of the file. Is there another command that can tell if a file has a truely active... (12 Replies)
Discussion started by: kchinnam
12 Replies

7. UNIX and Linux Applications

Notepad++ hang when open file edited in other text editor

Hi, I would like to ask about the notepad++ text editor application, Although there are alternative and more great text editor in linux (gedit, geany, jedit) im still using the notepad++ sometimes cause for some of my own reason one of those is the minimalist text(what i mean is notepad++ has a... (2 Replies)
Discussion started by: jao_madn
2 Replies

8. UNIX for Dummies Questions & Answers

Vi editor will not open new to UNIX. help please.

vi: syntax error at line 1: `)' unexpected when I try to vi into the /etc/vfstab, the return gives me the above error. how can resolve this so that I can have access into vi. (6 Replies)
Discussion started by: dovestar
6 Replies

9. Shell Programming and Scripting

Not able to read .csv file until open in vi editor

Hi, I am facing a problem regarding .csv file, my script does not read .csv file and if i open this file in vi editor and perform :wq option then only my script reads the .csv file. Thanks (5 Replies)
Discussion started by: ranabhavish
5 Replies

10. Shell Programming and Scripting

To check if a file is open and in use (logs are being written to it)

Hello Experts, I need to write a shell script to check if a file is open and something is being written to it. I want to know how OS handles it. I checked with lsof command but it is not working. For a test I did this. while true; do echo `date` >>abc.txt; done then I checked lsof |... (5 Replies)
Discussion started by: shekhar_4_u
5 Replies
fiu-ctrl(1)						      General Commands Manual						       fiu-ctrl(1)

NAME
fiu-ctrl - a script to remote control programs using libfiu SYNOPSIS
fiu-ctrl [options] PID [PID ...] DESCRIPTION
fiu-ctrl is a script to enable/disable failure points in running programs that are using libfiu(3). Programs are usually launched using fiu-run(1), which enables libfiu's remote control capabilities without the need to modify the program's code. For additional documentation, go to the project's website at http://blitiri.com.ar/p/libfiu. OPTIONS
-c command Run the given libfiu remote control command before executing the program (see below for reference). -f ctrlpath Set the default prefix for remote control over named pipes. Defaults to "$TMPDIR/fiu-ctrl", or "/tmp/fiu-ctrl" if "$TMPDIR" is not set, which is the usually correct for programs launched using fiu-run(1). Remote control commands are of the form "command param1=value1,param2=value2". Valid commands are: 'enable name=NAME' Enables the NAME failure point unconditionally. 'enable_random name=NAME,probability=P' Enables the NAME failure point with a probability of P. 'disable name=NAME' Disables the NAME failure point. All of the enable* commands can also optionally take failnum and failinfo parameters, analogous to the ones taken by the C functions. EXAMPLES
The following command will tell the process running with PID 12345 to enable the failure point posix/io/read with a 25% of probability to fail, and the failure point libc/mm/malloc with a 5% of probability to fail: fiu-ctrl -c 'enable_random name=posix/io/*,probability=0.25' -c 'enable_random name=libc/mm/*,probability=0.05' 12345 And the following will tell the same process to disable the previously enabled failure point posix/io/read: fiu-ctrl -c 'disable name=posix/io/read' 12345 SEE ALSO
libfiu(3), fiu-run(1). BUGS
If you want to report bugs, or have any questions or comments, just let me know at albertito@blitiri.com.ar. For more information about libfiu, you can go to http://blitiri.com.ar/p/libfiu. 16/Jun/2009 fiu-ctrl(1)
All times are GMT -4. The time now is 08:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy