Ubuntu :: Bash: Determine If Running In Terminal?
Jul 10, 2010
I'm writing a bash script to move files around based on various bits of metadata. For a few reasons, this script will be run regularly both from the terminal, and from the nautilus-scripts folder ("graphically", if you will). What I'm stumped on is having the script defer outputs based on which mode the script is running in. For example, how can I have the script know whether to echo error statements, or pump them out to zenity based on the method of invocation?
View 2 Replies
ADVERTISEMENT
Aug 9, 2011
Trying to write a script for desktop launchers that are adaptable to screen resolution. Ideally, the program should:
1. Determine screen resolution:
if "a" use xdotool options window size 1305 x 869 px and move to 135,0
if "b" use xdotool options window size 1545 x 1019 px and move to 135,0
2. Check if program running:
if no, open program, and use "a" or "b" placement options, focus window
if yes, focus window
3. Close script and leave program open (if possible).
Problems arise when trying to use the script on programs that run from and hog the terminal
(e.g. brasero, gcalctool, nautilus)
Here the script will load the program, and nothing else (probably because it still occupies the terminal as it runs)
Code:
gcalctool && xdotool search "calculator" windowmove 135 0
This next command will cause the program to load, move, but it keeps focusing itself like xdotool is running the windowmove function constantly - it keeps focusing itself until script stopped.
Code:
gcalctool & xdotool search "calculator" windowmove 135 0
This had the same effect as the above code, but seems to work as a conditional subscript running when the process is running in the terminal - it just goes infinitely.
Code:
while [1] ; do xdotool search "calculator" windowmove 135 0 done exit
Is there some kind of "if, then" or "while, do" or some kind of conditional I can put in to the script ensure the window is moved only once if the program is running within the terminal? Is there a way to remove the program from the terminal from the script once it's been called?
View 5 Replies
View Related
Jan 20, 2011
In windows command prompt, F8 key can cycle through your previously entered commands i.e say you enter "ping google.com" and then "pushd <dir>". Next when you type p and then press F8 brings pushd and next F8 brings ping command. You can then hit enter to execute the corresponding command i.e ping in this case.Is there anything similar in Ubuntu Terminal running bash? Very handy to get back previously entered commands.
View 3 Replies
View Related
Jun 25, 2010
I have a startup script for jboss (start.sh) that sets some JAVA_OPTS and then calls bash run.sh.If I run it (start.sh) from the command line it runs in the terminal fine. If I make a shortcut launcher for it in gnome and set it for 'application in terminal' it pops up then immediately dies after launch.Not sure what the problem is. Is this not working because one script is calling a second script? But then why does it work when I call ./start.sh?
View 4 Replies
View Related
Apr 17, 2011
In a shell script. And use that in a condition.
Something like:
Code:
if(pts) echo "emulated"
if(tty) echo "virtual"
View 3 Replies
View Related
Jun 3, 2010
I installed Apache by using the following command:
Code:
sudo apt-get install apache2
I later realized that there are two (or more versions) of Apache, MPM Worker (threadsafe) and Prefork. Since I'm trying to get both Tomcat and PHP working on the same system I need to know what version is installed of Apache, Worker or Prefork?
Looking in the package documentation, it said something about a virtual package... Looking inthe mods-enable directory, I don't see anything that indicates one or the other.
I'm also wondering if Tomcat integration can work with prefork?
View 1 Replies
View Related
Jan 4, 2010
How does one determine what KDE is running on a PC? Surely, there is a simple CLI command (or GUI) to determine that - but I don't know what it is..Something similar to "uname -a" that we use to find kernel version.
View 2 Replies
View Related
May 10, 2015
I cannot find a bash command: "file" !
It say "-bash: file: command not found"
"file" is used to determine file type on a bash right ? is there a package i have to install ? deprecated ?
I use debian wheezy distro
View 2 Replies
View Related
Feb 3, 2010
From the terminal, or a script, how can I determine the media type (CDDA, DVD, ISO, etc) of a mounted optical disc? I need this for an automated script on my headless media server - Fedora 12 64bit.
View 2 Replies
View Related
Dec 10, 2010
Linux-goers. I did some research on this, but I am still fairly new to Linux. In Ubuntu 10.10 (Maverick), I accidentally overwrote my "/bin/bash" file. Dude, using "sudo" with a small typo can work disasters. Bash is now broken in the Terminal (gnome-terminal). Terminal itself still works fine, technically, but bash is still hosed/broken. Here is what I did to try to fix it: Booted from Ubuntu 10.10 live CD. Mounted my Ubuntu partition and manually copied the good/fresh "bash" file onto my hard drive. Verified copy was successful. Didn't help, as you see. Reinstalled "gnome-terminal" using synaptic package manager. Tried to reinstall bash via synaptic, it failed with error, "E: /var/cache/apt/archives/bash_4.1-2ubuntu4_i386.deb: subprocess new pre-removal script returned error exit status 2"
In Terminal, all basic commands work as far as I can tell. ("ls", "pwd", navigation, etc.) Here are some problems:My "username@computername" does not display in the prompt; only the $ sign. Bash keyboard shortcuts such as uparrow and tab do not work. Instead, each inserts a key code. I can't even move the cursor left/right. Aliases (a function of bash and .bashrc) are broken, of course. My sanity level decreases when I use Terminal now. For what it's worth, even with "sudo" I get a "permission denied" error when trying to run Google Chrome! I read something about a ".bashrc" file being a possible problem, but I don't know how to make it work, or the file's proper locations in Ubuntu 10.10. Is there something I can do with a "make" or "apt-get install" command or something?? Could this simply be a permissions problem? Is the link to "/bin/bash", "/bin/sh", or a ".bashrc" file broken? Guide me, oh Linux gurus.
P.S. I always wondered what exactly bash was and how it was different from the basic terminal. LoL, this is an excellent way to demonstrate the difference, and I WANT IT BACK!
View 9 Replies
View Related
Jun 5, 2011
I got a problem with terminal, since i'm really a noob with terminal i don't know how to fix it.Everytime i type in a command it shows for example:
-bash: ls: command not found
Even the basic commands don't work... just cd <directory> and those things works
View 9 Replies
View Related
Jun 23, 2011
How can I programmatically determine if my python script is being run with a 32 or 64 bit interpreter? Better yet, is there a one-liner I can run that will print out the word size of the current python session?
View 6 Replies
View Related
Feb 29, 2016
I mainly use debian jessie , recently i have installed daragora as my second os to get a feel of gnu/linux . the problem is that dragora uses bash , and it's commands are different from debian jessie terminal is there a way that i can use the same commands here in dragora?
View 4 Replies
View Related
Jul 7, 2011
Can anyone tell me how I determine the version of linux my Synology Diskstation DS210+ is running?\
View 3 Replies
View Related
Nov 16, 2010
Checking the process table for the running sendmail, I would like to know the full path to the sendmail binary a la the ps -ef on a Sun or other servers. How do I get ps to give me the actual path, or should I use a different tool on my Linux servers?
View 2 Replies
View Related
Feb 22, 2011
What would be the best way to determine memory consumed by each application running on the server?
View 7 Replies
View Related
Jul 17, 2010
below are the details of my system. I have bash as my current shell, some really common commands aren't working.
Do I need to do a re-installation of bash? Or how do I install a selection of bash commands which I need? (for example a subset of [URL])
Code:
root@sdptfw:~ # uname -a
Linux sdptfw.sdpt.co.za 2.4.36 #1 Tue Jul 22 13:13:24 GMT 2008 i686 i686 i386 GNU/Linux
root@sdptfw:~ # echo $SHELL$
/bin/bash$
[Code]....
View 13 Replies
View Related
Jul 26, 2010
I presume there is something in the JWM window manager - or Puppy Linux Lupu 5.01 itself that is conflicting with the normal loading of GMPLAYER....
I would like to know how to troubleshoot, and fix this problem if possible (even a workaround would be great).
View 1 Replies
View Related
Apr 5, 2011
I would like to hear about a (telnet) terminal for Linux that can run VB scripts. The need is for configuration of a target board. I like secureCRT very much, but I can not use it from a Linux workstation.
View 4 Replies
View Related
Apr 28, 2011
I've noticed something, and hoped there was a work around.when I write a simple bash script, and run it, if I close the terminal i ran the bash script inside, the bash script stops. What are the solutions for this? Basically I want to run my bash script and close the terminal, keep the bash script running.
View 6 Replies
View Related
Apr 29, 2010
In KDE's Konsole, I can do the following from the terminal:
dcop kwin KWinInterface currentDesktop
And it will tell me which desktop my terminal is connected to ( per [URL])
How can I determine what desktop number the current gnome terminal in a gnome session is connected to?
View 1 Replies
View Related
Feb 15, 2010
terminal i open i have no history; the history is kept only in that terminal and is gone when i exit the terminal.If I count lines:as a user:
Code:
$ wc -l .bash_history
wc: .bash_history: Permission denied
[code]....
View 2 Replies
View Related
Apr 13, 2011
I'm trying to make a cheap bash script that will log me into a remote terminal. When I run the script, it prompts me for a password. I'd like to include the password entry into the bash script. How do I do this?
View 2 Replies
View Related
Apr 20, 2011
I wanted to change my $PATH and my prompt, had some trouble with setting and exporting the variables and found that the shell was csh instead of the bash which I expected. I worked around it by creating a .cshrc which calls bash but don't know what caused the change. I've got as far as seeing that the gnome-terminal command kicks it all off from the Applications>System Tools menu but what happens between there and the terminal popping up?
View 3 Replies
View Related
Mar 18, 2010
Im used to using nautilus within centos but have recently just got a VPS and quickly realising that using a KDE is unacceptable in this environment. Although I do find it so much quicker doing things like folder permissions in KDE rather than typing it all out in the terminal? Everyone I speak to says, use the terminal and I should learn this way as opposed to using the KDE, but theres certain things I just dont get
How is it possible to make quick changes to scripts and viewing them in a browser etc , without a mouse or using KDE? and only using a terminal?? I am wondering how to develop websites just using the terminal?
How can it be quicker to type out/view permissions etc in the terminal when its instant and just a few clicks in the KDE?
View 3 Replies
View Related
Mar 11, 2010
Is it possible to split a bash terminal window in to two colums so you can run and see multiple commands at once instead of having to flick between?
View 4 Replies
View Related
Aug 29, 2010
I have a basic script that watches my server, and informs me if it has gone down. I need to know how to run it without a console being open all of the time, I tried executing it with a trailing &, but to no avail.
Code:
for (( ; ; ))
do
if ping -b -c 1 chatify.net
then
[Code].....
View 3 Replies
View Related
Aug 25, 2010
I'm trying to run a script that launches a GUI using DirectFB while su'd as a different user. I probably have to add environmental variables but I'm not sure exactly what to do to get this working.
Here's the error I'm getting:
Code:
(*) DirectFB/Core: Single Application Core. (2009-06-02 06:26)
(*) Direct/Memcpy: Using libc memcpy()
(!) Direct/Util: opening '/dev/fb0' and '/dev/fb/0' failed
--> No such file or directory
[Code]....
View 2 Replies
View Related
Apr 6, 2011
this has been driving me crazy all week, no matter what I try it just wont work.I have written a script that installs several programs, half way through it requires the machine to be rebooted.what I've been trying do do without success, is when the system restarts a terminal window opens and the script resumes.I've googled this, and it seems other people have aslo tried and failed to acheive the desired result.ok, I know it would be easy to just run the script without the terminal window (using cron @reboot or rc.local), but I really need the verbose output as the user must make 2 selections on the remaing installations.
View 3 Replies
View Related
Jan 5, 2010
Is running a command in the Alt+F2 prompt possible in a bash script?I need this for a launcher for gnome-shell.For it I have written a little script to check if the process gnome-shell is alive and act accordingly.The script works fine, I just don't know how to write "debugexit" to the Alt+F2 prompt, as that is the only decent way I have found to shut gnome-shell down and going back to gdm desktop smoothly.
View 1 Replies
View Related