Programming :: Referring To The Current Terminal In A Bash Script?

Dec 22, 2010

I've got some bash scripts that I'm testing which operate on different screen sessions under different usernames. In order to check the status of them, however, I have to attach the screen sessions to my current terminal.

I run into problems, though; I only allow SSH to my machine from one username; the others shouldn't need SSH access. So, I log in as one user, and su into whichever user I need. Without performing a chmod o+rw on the terminal before I su into a different user, screen complains that it can't reattach to my terminal, because the user trying to make it attach doesn't have the permissions to do so.

Seeing as I forget to do this a lot, I wanted to make a script that I'd run on log-in to do this for me. Unfortunately, I don't know if there's a bash variable that refers to the current terminal - I can't always guarantee that I'll be logging in to /dev/pts/0, especially if my internet connection gets cut and I leave a hanging terminal...

Is there a variable for that or a way to refer to it in a script? If not, how do I work around that?

View 4 Replies


ADVERTISEMENT

General :: Referring To Variables In Bash?

Sep 13, 2010

Is there a difference when variables are referred to as $variableName and ${variableName} in bash?

View 1 Replies View Related

General :: Bash Script - Obtain Current Workdirs Of All Konsole Terminal/sessions?

Jan 15, 2011

I am trying to write a bash script that would save the current state of my konsole terminals and sessions. I'm using KDE3.X and for some reason the "profile" save does not save the current working directories... Anyway, I would like to know if there is an elegant way to obtain the current workdir of each terminal and session ? I've managed to do something with a clever use of DCOP extended functions, but it requires me to start every konsole with the --script option enabled, and I don't want to do that.

View 9 Replies View Related

Programming :: Bash Script To Start Gnome Terminal?

Apr 8, 2010

I want to write a bash script which can open a new gnome-terminal window.
In that gnome-terminal window, it should goto a specific directory and edit a file using Vi Editor.

How is it possible to do that?

View 7 Replies View Related

Programming :: Write A Bash Script To Call From A Terminal?

May 24, 2010

I am trying to write a bash script to call from a terminal that will change the terminal title. I am using ubuntu 10.04. The script is meant to be used in the gnome-terminal.

Here is what I have:

Code: #! bin/bash
echo "New title: c"
read title
echo "33]0;$titl07c" -e

[Code]....

it doesn't work

I think the problem has to do with modifying PS1 inside the bash so i tried this:

Code: echo `export PS1="[e]1;u@h:wa]${debian_chroot:+($debian_chroot)}u@h:w$ "` and it still didn't work.

View 1 Replies View Related

Programming :: Run A Command On A Separate Terminal In A Bash Script?

Apr 6, 2011

I'm trying to do something here:: I'm writing a bash script, I want to [open a new terminal and run a bash command in it] inside the script. I tried to use this, but apparently I get syntax errors.

Quote:

#! /bin/bash
echo "echo Something" > ~/Second.sh
chmod +x ~/Second.sh
xterm -e sh -c ./Second.sh

View 14 Replies View Related

Programming :: Bash - Use The Call Command (displays The Current Month And The Next Month)?

Mar 8, 2011

how i can use the cal command so it displays the current month and the next month, i know you can use cal -3 9 2007 to show the previous current and next but i just want to display the current and next.

View 9 Replies View Related

Programming :: Awk/bash - "current Dir" - Script On A File In A Subfolder

Apr 25, 2011

I have a script (bash) that do some editing and stats on different logs (syslog) and output a file (html format). If i want to run the script on a file in a subfolder as the script where in that folder how do i do that?

Code:

makes a file called index.html with some stats from the syslog file.

if i run the script on a file in a subfolder

Code:

the script makes a output in the base folder, i want it to print the file to the test folder. There are multiple subolder and i want a index.html in each of them.

View 3 Replies View Related

Programming :: Write A Bash Script Program In System Command Terminal?

Mar 22, 2010

I'm trying to write a bash script program in the Linux command terminal that will write to a fellow user and then continue reading down the program. this is what i have (kind of explains the idea too):

#!/bin/sh

clear
echo "this is before the write command"
write jcummins
this message should go to jerry
echo "the message didn't send and this string will not appear"
echo "it appears it has stopped at the write command"

View 5 Replies View Related

Programming :: Invoke Java From Bash Terminal Via Shell Script Fails Under Mint Debian / Fix It?

Feb 16, 2011

I am running a Java application on the command line bash terminal under Mint Debian. I have JDK1.6.0_22 installed 64-bit, and the OS is 64-bit too. I have a few JAR files in the directory and a few native LWJGL libraries. When I run the application using the command line, all works fine.
Lets assume my directory where the files are is called /home/riz/MyGame. I change to that directory and this is the command I use code...

View 3 Replies View Related

Debian :: Change Dragora Bash Terminal To Default Jessie Terminal

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

Ubuntu :: Bash Broken, Lost Functionality In Terminal (gnome-terminal)?

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

Ubuntu :: Terminal Bash / -bash: Ls: Command Not Found

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

Debian Multimedia :: Basic Networking - Referring To Computers By Name

May 16, 2011

Sorry if this is a dumb question, there's a lot about networking that I don't get yet. I've got two computers using the same wireless router. They both get their IP addresses via DHCP from the router (I assume). If I want to connect from one machine to another, I can use the IP address (which works), but it's a pain checking what the IP address is, I guess it depends on which one connects first? So it might work today but tomorrow the IP addresses are reversed and the same command wouldn't work.

What I'd like to do is just refer to the other computer by name, but of course I haven't got a DNS server just for these two computers, and I don't think the router can do it (can it?) so is there a way to do it? Is it really just a case of switching off DHCP and giving each computer a fixed and unique IP address, and then entering some name in the hosts file for the two computers? Although then there's nothing to guarantee that the name in the hosts file actually matches the hostname of the computer at that IP I suppose.

View 5 Replies View Related

Networking :: Automaticaly Get Current URL Address For Use In Bash?

Sep 16, 2010

I've tried hardy to grab URL adress from my firefox "address bar" with bash. Is there any way to capture current url adress(or current url location, or current domain) from any decent browser (or by listening to own traffic.)

View 3 Replies View Related

Slackware :: Sbopkg - B0rked By Bash Upgrade In - Current?

Mar 3, 2010

I recently upgraded my -current box, and now when I try to run sbopkg I get the exact error described in the following thread:[URL].. The error fwiw is as follows:

root@catbutt:~# sbopkg
ERROR
sbopkg: Invalid repository descriptor
Line
SBo 13.0 "SBo repository for Slackware 13.0" _SBo rsync slackbuilds.org::slackbuilds/13.0 GPG
of
/etc/sbopkg/repos.d/40-sbo.repo
specifies an unknown fetching tool (rsync).

seems likely given the discussion in that previous thread that the bash upgrade (to 4.1.002) in the recent -current onslaught is responsible?

View 6 Replies View Related

Slackware :: If Close Terminal Ran Bash Script Inside / Bash Script Stops

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

Software :: Strace Crashes Shell/system When Being Used On Current Bash?

Jun 8, 2011

I am observing a very strange behavior when using strace and don't know the reasons for it.

I do: pstree -Aapnul |less -p bash on my Ubuntu VM which is run with the help of Virtual Box.

I see:

|-gnome-terminal,1418,valentin
| |-gnome-pty-helpe,1419
| |-bash,1420
| | |-pstree,1471 -Aapnul

[Code]....

View 1 Replies View Related

Ubuntu :: Show Current Commands In Terminal?

Jan 6, 2010

I was wondering if there was a way to show all current actions I am doing in a terminal window? For example if I left a terminal window open on one of my desktops, could I make it display everything I am doing so that when I receive some general error in a program, I could jump over and get some more details. I could also use it to see what commands are actually run when I do certain things.

View 1 Replies View Related

Ubuntu :: Display Just The Current Directory In Terminal?

Jul 14, 2010

when we navigate into directories withing directories the terminal displays the entire path right from the root. Now how to make it just show the current directory I am working in? For examplevineeth@vineeth-laptop:~/Desktop/linux_programming/python_programming/project_duplicate_zip_files$ as you can see that I am in the current project_duplicate_zip_files directory but it displays right from the root. how to just make it something like below:vineeth@vineeth-laptop:/project_duplicate_zip_files$

View 2 Replies View Related

Ubuntu :: Open A Terminal Under The Current Directory?

Oct 10, 2010

So for example, I go to PLACES -> DOWNLOADS and somehow open up a terminal for that rather than opening up a terminal to type "cd ~/Downloads" I know its simple to do that but when your dealing with some crazy directory like:

/media/2TB-DATA/BackUps/Regular/Downloads/Pictures/Family/Me/HiDef/ or something, and ur already browsing through it using the file browser, it would be nice to be able to open up a terminal for that directory.

View 6 Replies View Related

Ubuntu :: Change Prompt For Current Terminal Only?

Feb 7, 2011

I program in C with geany and two terminals open; one to compile and one to test the compiled program. The thing is that it's hard to the eyes to keep track of the messages and such when the terminal prompt is too long:

Code:
manos@manos-desktop:/media/Iomega1TB/Documents/UNI/Datastrukturer och Algoritmer/labbar/lab1$

How can I change that to something minimal? I don't want a permanent solution as all other times I want to be aware of the current path.

View 3 Replies View Related

Ubuntu :: Terminal Split Current Screen

Mar 5, 2011

As I am getting to know the Ubuntu terminal, I am looking for this application that can automatically divide the current screen by showing a Terminal window at the top.

i already set up a shortcut to open the traditional terminal Window, also i know of the full screen terminal window by pressing ATL+F1 but as I am reading a tutorial I would find it convenient to simply type above the screen while reading the bottom

View 1 Replies View Related

Fedora :: Bash Function Alias To Recursively Grep Current Directory?

Feb 14, 2011

This should be a simple thing to accomplish, but I can seem to figure it out. Essentially, I want to have a bash alias or function that will let me recursively grep the current directory. A while back I added this to my .bashrc:

Code:

alias rg="grep -r --exclude=*/.svn/* --exclude=*.swp"

This works fine, (and also ignores any svn and vim swp files), and I can call it like:

Code:

rg foo *

However, 99.999% of the time, I am only interested in searching in the current directory, so the "*" is a bit redundant. Also, I would say 5-10% of the time, I am typing faster than thinking and forget the "*", so grep just sits there trying to read from stdin. It's a pretty minor thing, but ideally I'd like to be able to just type:

Code:

rg foo

I've tried creating a function to handle this:

Code:

function rg(){
grep -r --exclude=*/.svn/* --exclude=*.swp $1 *
}

but it behaves exactly the same as the alias above. escaping the "*" with 's doesn't work, and neither does trying `pwd` (or even a hard-coded path) in its place.

View 2 Replies View Related

General :: Bash History And Keeping Track Of Current Working Directory?

Jun 8, 2010

I would like to keep track of not only what bash commands I used and when, but also where they were issued from, i.e. what was the current working directory when I issued "foobar" on a particular day and time. Can we ask bash history to keep track of working directories too? I have tried to get an idea of this reading the enormous "man bash", but I don't seem to have an answer yet either way.

View 11 Replies View Related

General :: Configure Bash Prompt To Show Current / Parent Directory Only

Oct 15, 2010

I would like to modify Bash Prompt so it does not show the whole $PATH but just the current and parent directory. I am using Ubuntu.

View 3 Replies View Related

Programming :: Bash: Printing The Line Number In Bash Script?

Feb 4, 2011

I would like to know how do I print the line # in a script. My requirement is, I have a script which is about ~5000 lines long. If there are any errors happen I just exit. And I would like to add the line # of the script where the error happened.

View 3 Replies View Related

Programming :: Bash Ctrl+c Tarp And Bash Read With Timeout?

Jan 24, 2010

simple bash code:

Code:
#!/bin/bash
trap "echo 'you got me'" SIGINT SIGTERM # to trap ctrl+c
echo "Press ctrl+c during 5 sec loop"
for ((i=0;i<5;i++)); do

[Code]...

How come code behaves normally and stops when ctrl+c signal is caught and resumes, but after I use at least one timeout read in the code it looks like, if signal is caught again it doesn't pause the execution but skips the loop. If you remove -t (timeout) option from the read, both loops look the same!

View 10 Replies View Related

Ubuntu :: Opening Current Directory In Nautilus From Terminal?

May 20, 2010

Like the title says, I want to be able to open the directory I'm browsing in nautilus.To clarify this, as I barely understand what I said, I'll give an example.

Code:
cd ~/what/ever/this/is/complex/path
Hmmm.... A lot of files in here with long complex names and I only want to move certain ones..... Better open it in nautilus with my handy dandy script/alias!

View 4 Replies View Related

Ubuntu :: Open Terminal To Current Directory In Nautilus?

Jun 1, 2010

what I'd like to have is a way to open a terminal directly from Nautilus and the terminal's active directory should be the one that is opened in Nautilus. Does Nautilus have a plugin system or is there another way to add this functionality?

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved