I have this idea - Copying between different terminal directories.

Hi,
I have no idea if a program that does the following exists. The concept is a bit hard to explain but I'll do my best.
Lets say that you have to terminals opened. In terminal 1 you are currently working in ~/build/foobar and in terminal 2 you are working in ~/archiscool/foobar/letshaveadrink/ and you want to copy a file from ~/build/foobar to ~/archiscool/foobar/letshaveadrink. The usual way of doing this would be to type
"[user@host ~/build/foobar/]$ cp foobar ~/archiscool/foobar/letshaveadrink/"
and it is usually very quick to do with completion, but it would be much easier if one could build a script (lets call it "t2dir") that could identify the working dir of terminal 2. Then you'd only have to type
"[user@host~/build/foobar/]$ cp foobar t2dir".
Would it possible to probe terminals for their working directories?
Last edited by Ashren (2008-04-17 09:47:00)

Here's an alternative: use `ls /dev/pts` to get a list of running ttys and present that list to the user and let them choose the destination. That way they won't have to know the "/dev/pts" number of the tty they want to copy to. It will be nice to people who use title-bar-less windows (like me).
#!/bin/sh
# Find out the PIDS of running ttys
PIDS=""
for PTS in $(ls /dev/pts); do
#echo "$PTS"
PID=$(pgrep -nt "pts/$PTS")
#echo "$PID"
if [ $PID != $$ ]; then
PIDS="$PIDS $PID"
fi
done
# Count the PIDS
i=0
for PID in $PIDS; do
i=$(($i + 1))
done
# Behave differently based on number of available destinations
case $i in
0)
echo "No other tty to copy to. Ignoring."
exit 1
1)
DEST=$(pwdx $PIDS)
#echo "$DEST"
echo "Only one possible destination. Copying to $DEST."
exit $(cp "$1" "$DEST")
*) # Many destinations
j=0
for PID in $PIDS; do
j=$(($j + 1))
echo "$j. $(pwdx $PID | sed -r -e's/^[0-9]+: //')"
done
echo "Select destination by entering its number (1, 2, etc.): "
read NUM
if [ $NUM -lt 1 ]; then
echo "Error: there is no number smaller than 1 in the list."
exit 2
elif [ $NUM -gt $j ]; then
echo "Error: there is no number greater than $j in the list."
exit 3
elif [ $NUM -gt 0 ] && [ $NUM -le $j ]; then
k=1
for PID in $PIDS; do
if [ $k -eq $NUM ]; then
DEST="$(pwdx $PID | sed -r -e's/^[0-9]+: //')"
exit $(cp "$1" "$DEST")
fi
k=$(($k + 1))
done
else
echo "Error: cannot understand what you wrote."
exit 4
fi
esac
When in sh, I'm paranoid about spaces and metacharacters and globs and I don't know how to use arrays. I guess this explains the weird structure of the script.
It sucks that it doesn't check for duplicates when listing out possible destinations... I should write this in a more comfortable language like perl. But I should go do some real work now.
Last edited by peets (2008-04-18 14:39:04)

Similar Messages

  • Client copy between different operating systems.

    Hi Experts,
    Our production system is running on HP-UX OS. We are installing a standby quality system and planning to do a client copy to this system from production by taking this into transport domain. But this new system is in windows. So, is it possible to perform a client copy where the source system is HP -UX and target system is windows??
    Regards,
    Amit.

    Hi Amit,
    Follow SAP Note 552711 for client copy. Refer to qns no 4 & 5, which is relevant for your question.
    Can I create client copies in a heterogeneous system landscape?
    Remote copies or client transports can also be carried out between different database and operating systems.
    Regards,
    Debasis.

  • I have this idea...  Browser inside a java bean area

    10G forms
    As I see questions pop up in this forum I notice that people want to do some of the same things in forms that one can do in a browser. Like Flash.. Or play a movie. Since, Im not a java expert, I have this thought, and would like any Java Bean experts to respond. I am not afraid to write Java code and will attempt to write this myself if it sounds feasible. I just need a "go for it" or "it sounds good" from some knowledgable forms/java developers.
    So.. Heres what I want to do...
    Basically why can't we as forms developers create a java bean area and open the default browser of the client inside the area? If we can do that then we can display flash, play a movie, run an oracle report inside a form? Cant we? We could then do whatever the browser can do inside a form java bean area?
    Here is my requirement that makes me want to do this...
    The requirement is "Can you display the output of an Oracle Report inside of a oracle form?" The users do not want the report output in a separate window. They want to surround report with form fields. An operater will look at the report in the center of the form, interpret hand written text (image), and update the form fields around the report with correct values. This report is very complicated. It converts xml and also converts base64 encoded images to jpegs overlaying these values on another large image of a state police form. Since this report already does all of this, we would like to just display the report output inside the form and not rewrite the whole thing so a form can do it too.
    Comments are appreciated..
    Im actually hoping Francois gets intriqued way over there in Paris as he sometimes does with these java questions :)
    Message was edited by:
    Mark Reichman

    I've seen an example that shows how to embed MS-Word within an applet, using OLE automation, so I suspect that doing this with Internet Explorer could be achieved. It's an interesting example, called Snippet157 -- part of the Eclipse project. It also demonstrates using the SWT-AWT bridge, whose purpose is to allow AWT and SWT components to be used together. You don't need Eclipse to run the snippet, but you would need to download SWT from http://www.eclipse.org/swt (the SWT-AWT bridge is included.) Whether this example could be adapted to pure Swing/AWT, and how easily that could be accomplished, is beyond my present level of expertise.
    As for using this approach with other browsers, I'm not sure that all browsers provide automation hooks, so embedding the default browser may not be so easy. Finally, trends toward tightening browser security may lead Microsoft to prevent or restrict automating even Internet Explorer.
    This is all I can think of -- Francois & Frank probably have more insightful suggestions.
    Hope this helps,
    Eric Adamson
    Lansing, Michigan

  • Pass values between different frames

    Dear Friends from Adobe.
    I need a lot of help from you.
    I have a project with Flash Action Script 2.0 and would like
    to know if you have to pass values between different frames.
    Example:
    Passing a value of a inputbox the frame 1 for a inputbox in
    frame 2.
    OBS: If possible could pass the solution through e-mail?
    Now, very grateful.
    Diogo Areas.

    Using AS2 you can either name the input textfield instance on
    the stage or, you can name the variable property of the input
    textfield. You can name either of these from the Property Inspector
    window. Once named, you can then have access to the value of the
    text that is entered. It will be either instanceName.text or
    variableName.
    The scope of either of these values lasts only as long as the
    textfield instance exists. So, if the first textfield is in frame
    7, for instance, and is only in frame 7, and you want to use the
    value in another frame, say frame 20, then you'll have to store the
    value outside of the textfield for later use. You can do this by
    creating a variable in the first frame of the movie, and then
    placing the text from the textfield in frame 7 into that variable.
    Then at frame 20, you can retreive that value and use it in the
    textfield in frame 20.
    Alternately, you can continue the instance of the textfield
    in frame 7 out through frame 20. The content will continue to be
    available. You can add keyframes to the layer that the textfield is
    in at frame 7, and move the object off the visible area of the
    stage, so that it won't be seen, if you like.

  • How do i save a copy of my emails on the server on a macook pro? I am having a problem when using hotmail on my new macbook, they say it is set pop3? i have not idea what this means!

    I am not very good on computers and need help, I have lost past history emails when i have used hotmail on my new macbook, they say it is not set right but i do not understand! they say I need to ensure the box 'save a copy to the server' is ticked but they can not help me locate this and I have no idea what to do, can anyone talk me through this please?

    Check your mail preferences. The example below is from the mail app that comes with mac. In my case I'm using yahoo mail which is a POP3 account. POP stands for post office protocol which is the set of rules used by a POP mail account to transfer mail. You can learn more about it here if interested. If the box below is checked, all the mail will be downloaded to your computer when you check your mail using the built in mail app and removed from the mail server. Here is another page to help you set up your hotmail account for use the the mac mail application. Hope this clears things up.

  • HT1203 i have tried this 6+ times to "How to share music between different accounts on a single computer" on my wifes mac and can not get it to work!! On my PC no problem but on the MAC it will not work, follow the instructions to the T but no go????

    i have tried this 6+ times to "How to share music between different accounts on a single computer" on my wifes mac and can not get it to work!! On my PC no problem but on the MAC it will not work, follow the instructions to the T but no go????

    It is almost as if the program does not exist on my computer. If I search for it, the only thing that comes up is the installer. I cannot find it anywhere despite the fact I have installed it numerous times, uninstalled it and conducted a fresh install, and the Adobe website checks says that it is installed.

  • I can't upload a copy I got of Adobe Photoshop CS on my Mac Mini OS X 10.5.8. All I can get for why is this  "This program cannot be run in DOS mode" I have no idea what this means?

    I can't upload a copy I got of Adobe Photoshop CS on my Mac Mini OS X 10.5.8. All I can get for why is this
    "This program cannot be run in DOS mode"
    I have no idea what this means?

    Are you certain the copy of Adobe Photoshop CS is for the Mac OS, not Windows?

  • Sharing music between different accounts - is this how it works?

    The way iTunes shares music between different users seems a bit poor.
    I have two user accounts set up on the same PC, with music files accessed by each from the same folder (as described here: How To Share Music Between Different Accounts On A Single Computer).
    My main issues are:
    1) I have to manually add new music added by the other user instead of it just appearing in iTunes.
    2) iTunes doesn't recognise if a music file is already in the joint library, so we end up with two copies of things (particularly tiresome for podcasts).
    Am I doing something wrong - maybe there is an easy way around this?
    ... or do the people at Apple need to do a bit of work here?
    Pentium 4   Windows XP  

    By default, any new file or folder created is set to be read+write for the creator, and read-only for everyone else. The file creator can grant write access to other users by changing the permissions on a folder and its contents, as Neil suggests. But you'll have to repeat that process every time a new file is added.
    Fortunately, there is a way to automatically grant read+write access to all files created or copied to the folder. First go to System Preferences -> Accounts. Click the + button under the users list. Then, make a new group; calling it "sharegroup" or something similar. Add the users you want to the group.
    Then put all the files you want to share into a commonly-accessible folder, such as a subfolder in /Users/Shared.
    Then log in to an admin account and open Terminal. Paste in the following two lines:
    sudo chmod -R +a "sharegroup allow delete,chown,list,search,add_file,\
    addsubdirectory,delete_child,file_inherit,directoryinherit" \
    Press return, then drag the folder into the Terminal window, and press return again. Enter admin password when prompted and press return. That should do it. Everything there now should be fully writable by all users in sharegroup. New files that are *created in* or *copied to* the folder will be the same way.
    Files that you *move in* from a different location on the same hard drive won't be, though. So make sure you copy previously existing files into the sharefolder instead of moving them (hold down option key while dragging to copy) so that they get the custom permissions applied.

  • HT201210 Iphone 3gs needs to restore as cannot turn phone on but cannot restore as unknown error 2001 keeps coming up.   I have tried several times on different computers. Any help or ideas?

    Iphone 3gs needs to restore as I cannot turn phone on but cannot restore as unknown error 2001 keeps coming up.  
    I have tried several times on different computers. Any help or ideas? Thanks

    Hi there Katherine,
    I have an article here that addresses this error code and can give you a few more troubleshooting suggestions for this issue:
    Resolve specific iTunes update and restore errors
    http://support.apple.com/kb/ts3694
    Check USB connections
    If there’s an issue with the USB port, cable, dock, or hub, or if the device becomes disconnected during restore, try troubleshooting the USB connection, then troubleshooting your security software.
    Common errors: 13, 14, 1600-1629, 1643-1650, 2000-2009, 4000, 4005, 4013, 4014, 4016, “invalid response”, and being prompted to restore again after a restore completes.
    To narrow down the issue, you can also change up your hardware:
    Use another USB cable.
    Plug your cable into a different USB port on your computer.
    Try a different dock connector (or no dock).
    Add (or remove) a USB hub between your device and computer.
    Connect your computer directly to your Internet source, with no routers, hubs, or switches.
    If you see your error after changing your USB connections, continue to the next section to troubleshoot your hardware.
    Thanks for coming to the Apple Support Communities!
    Regards,
    Braden

  • I have more than 7600 duplicates in itunes! I have no idea how this happened. How do I efficiently get rid of them without deleting one at a time?

    I have 7600 duplicates on my itunes account. I have no idea how this happened and want to delete the duplicates en mass.
    Is it possible? How would I do it?
    This happened just recently.
    I do have a backup on My Book that may not have the duplicates. Not sure I WANT TO GO NUCLEAR THOUGH AND DELETE ALL THE DUPLICATES.
    ANY HELP WOULD BE APPRECIATED.
    THANK YOU.
    TODD

    If you've recently created a bunch of duplicates then, with the main Music playlist showing, hold down Option (Mac) or Shift (PC) and then the menu File > Display Exact Duplicates. Sort the resulting list on the Date Added field, select the range of tracks representing the recent imports which you know to be duplicates and delete.
    To delete any older duplicates scattered through the library sort the list in a conventional order like Album by Artist and delete all but one copy of each cluster of identical tracks.
    Normally when you delete the duplicate entries from the library you will also want to delete the underlying files, however in certain circumstances it is possible for iTunes to make two separate entries to the same physical file on your hard drive. In this case deleting the file for the one entry will break the other one. If possible try to work out which type of duplicates you have before deleting any files, and check that the remaining entries play before emptying the trash.
    tt2

  • HT201272 I am tryying to make a song purchase on iTunes from the only computer I have made purchases from. iTunes has just told me that I have never made a purchse from this computer before. It is asking me security questions I have no idea what the answe

    I have checked the emails that I have on file and they are correct. When I press the "Send email" button to help reset security information it is sending it to an email address that I have never ever had! Why is it not sending the email to one of the two emai addresses that ARE on file? I have no idea why it is even sending anything to that email adress or where it came from.
    I have money on my account. My account is now locked. It is sending instructions to an emai address that I have never seen before. I cannot find anyway to get phone support. I have a feeling this is going to take at lest a week if not longer to fix.
    Can anything be done...??

    Unfortunately you've discovered too late how important it is to maintain an up-to-date backup of your iTunes library (and all other data of value).  You could, before wiping the drive, have considered making use of a commercial data recovery service that could (albeit at considerable cost) have extracted your library from the hard disk, even if virus infected.
    In the absence of that option, you will need to restore the content of your library from its original sources:
    Depending on your location, you may be able to re-download any iTunes Store purchases that are still available on the Store
    Likewise, most digital purchases from Amazon (including auto-rip copies of purchased CDs) should be available from the Amazon Cloud and via the Amazon Music application - the same may be true of other commercial sources for digital downloads
    Content imported from your CDs will have to imported again
    The specific situation that you describe regarding the music imported from your friend's external HDD suggests that either the source is badly organized and/or originates from a source other than iTunes (other media players may use alternative tags for information like artist, title, album, etc. that are not wholly consistent with how iTunes handle these).  Without details of the issues you're seeing it is difficult to suggest a remedy other than going through the media album-by-album, track-by-track, and correcting the inconsistencies.
    In the absence of a backup or access to the original library data there is no option other than painstakingly recreating your library as described above.  As you do so, you'll now realize how important creating and maintaining backups are - in my case I have at all times three separate duplicates of my library, in two different locations, where none is ever more than a week old compared to the content of my master library.

  • I have never set a firmware password on my macbook pro, but when I hold down option to boot from a different drive, I get a lock, and have no idea what the password is..?

    I have never set a firmware password on mymacbook pro, but when I hold down option to boot from a different drive, I geta lock, and have no idea what the password is, i am the first owner of my mac so its impossible that someone else has set the password, i have only noticed this becuae i made a bootcamp partition and installed windows onto the machine, after the installation... i shut down the comptuer and continued to use os x, days later i tried to boot into the boot camp partition again by holding down the option key on boot, but i got a window asking me for a firmware password that i have no idea of! please help me!
    will

    Hi macbookprowilliam, I have the SAME problem, that grey lock just appeared trolling me. I dunno the password and I wan't to sell this macbook! I need the password. Maybe it's a new malware! I don't even know how to set a firmware password and I am the only user on this computer too! I have a thread about that too: https://discussions.apple.com/thread/3926399?start=0&tstart=0
    So, did you fix it or got around it? Please reply! I am desperate.
    Thank you

  • I have a MacBook Pro, Matshita UJ-857E while recording music my drive reported an error: Sense Key=HARDWARE ERROR Sense Code=0x03,0x01 I have no idea what this means, and now my cd burner/player won't work. can someone help me fix this problem?

    Please Help me. I am having problems with my MATSHITA UJ-857E DVD-R burner/writer. I burned 4 cd's and then it stopped working.
    I can select my songs, and then it asks for a blank disc. It starts preparing to write the disc,then it says,"
    The drive reported an error: Sense Key= HARDWARE ERROR Sense Code= 0x09,0x01 TRACKING SERVO FAILURE.
    Can anyone give me some advice on how to fix it or what this means because I have no idea what it is talking about or how to begin to fix the problem?

    tanyafrombakersfield wrote:
    It starts preparing to write the disc,then it says,"
    The drive reported an error: Sense Key= HARDWARE ERROR Sense Code= 0x09,0x01 TRACKING SERVO FAILURE.
    This is an error reported by the optical drive's firmware. The tracking servo is the servomechanism which guides the laser pickup along the track on the optical disc. The error means that the servo couldn't do its job within the programmed parameters. What it doesn't say is why.
    You have to be very precise as to when this error occurs. If it occurs as you wrote, while it "starts preparing to write the disc", and not when it has actually began to burn, then it's likely that the drive has gone bad and needs to be replaced.
    There are other possibilities, so you should check them, but they would be more likely if the error occurred after the drive began to write. OrangeMarlin has suggested two options -- try a different brand of CD or DVD, and try cleaning the lens.

  • HT1146 I can not get my mail to send on my mac. It has been fine until about 2 hours ago, incoming mails are fine. I have jused all of my 3 accounts and I can't send from any og them (they are all on different servers) anyone have nay ideas on how I can f

    I can not get my mail to send on my mac. It has been fine until about 2 hours ago, incoming mails are fine. I have jused all of my 3 accounts and I can't send from any og them (they are all on different servers) anyone have nay ideas on how I can fix this?

    Jailbreaking violates the Apple warranty and licensing agreement and voids ALL support from Apple.  No one on here can help you as doing so is a violation of the Terms of Use of these Communities.  If you send the iPad to Apple they will just send it back to you as they are not permitted to work on a machine that has been jailbroken.

  • You need to have xlsm where you can access the macro in numbers.  this is frustrating that the idea of Numbers is to make it like Excel yet you dont have this capability.  Question is, when will it happen or will it happen????

    You need to have xlsm where you can access the macro in numbers.  this is frustrating that the idea of Numbers is to make it like Excel yet you dont have this capability.  Question is, when will it happen or will it happen????

    Hi brev,
    Several points here:
    1. Although there is some compatibility between Numbers and Excel files, I doubt very much that "the idea of Numbers is to make it like Excel." The two applications share some similarities, but also have several differences.
    2. Your Question is unanswerable in this forum. Apple does not generally reveal future development plans or schedules for its applications, and anyone with knowledge of those plans will be bound by a non-disclosure agreement.
    3. "You need to" implies a feature request. If you want to request that a feature be added to a future version of Numbers, that request is better made directly to Apple, via the Feedback channel, than here, where the readers and responders are all users of the software, not developers. From the application menu (the "Numbers" menu in Numbers), choose Provide Numbers Feedback, then make your request for a feature to be added to Numbers.
    Meantime, if you absolutely need the macros capabilities of MS Excel, try one of the Office clones—OpenOffice.org, LibreOffice, or NeoOffice, which may offer macro support, or use the Mac version of Excel itself.
    Regards,
    Barry

Maybe you are looking for