OpenSUSE :: Export Variable In Subshell Back Out To Parent?
Apr 29, 2011Is there any way to use "export" inside a bash script that will affect the variable in the parent process (i.e. the terminal where the script was run)?
View 5 RepliesIs there any way to use "export" inside a bash script that will affect the variable in the parent process (i.e. the terminal where the script was run)?
View 5 RepliesIs there a way to export a variable to parent shell in shell scripting ?
View 3 Replies View RelatedI am stuck at a issue in shell scripting. I had tried all the possible ways, yet unable to reach a solutions. I am working on a application, which runs on C shell. For this I had created a installation script, which installs my application in the system, it is working fine. Now, the problematic part is that I had set an alias in ".cshrc" file, which invokes my application when any user types it. But for an alias to take effect, I need to re-login into the system, because I have to read ".cshrc" file again, in order to take effect of my alias. However I can use "source ~/.cshrc" file after my installation, so that my aliasing works without logging back again. But Requirement is that, just after installing the application, alias should be available to user, without logging back again and without issuing any extra command.
I had tried one other way is that, I had created a symbolic link in ~/bin directory, which points to my application to be run, but even that require, to issue rehash command in order to modify internal command hash table. So, my overall problem is that changing alias in subshell should be reflected to parent shell,without running any other command (all commands should be run in installation script only). Or, in other way how to rehash parent shell from subshell. The ultimate requirement is that,the command that will run my application, should be available just after executing the installation script, either by aliasing or by rehashing, or by any other means.
Code:
int main()
{
int pi;
int i=10;
pid=fork();
[code]....
Q 1. The value of the variable pid returned by the fork() function will be greater than 0 in the parent process and equal to zero in the child process? but during forking, there values are exactly copied so what's went wrong here?
Q 2. "changes to the variable in one process is not reflected in the other process" why it is so? >> Even if we have variable i declared as a pointer or a global it wont make a difference.
Code:
int main()
{
int i, pid;
i=10;
printf("before fork i is %d
[code]....
Q. Through this program it is clear that both process is using the data from the same location, so where's the original value is residing when the child process is in execution.?
I need to be able to set a variable that is used by my build environment. I need to be able to change this variable "on the fly" as I work with multiple build environments. A portion of the variable is arbitrary, so I need to treat the arbitrary portion of the variable as an argument.
I would normally just create an alias, but BASH doesn't support arguments to aliases. So the workaround for the no-alias-arguments bug is to use a script. No problem. Except the variable I set in the script does not exist when I exit the script.Now, if I run the script by using "$ . myscript" it works in that the variable is set after it exits. The problem is the argument checking I have in the script doesn't work anymore. BASH aliases don't support arguments and I can't export a variable from a script unless I source the script (is it even a script at that point?) Maybe I am simply taking the wrong approach.
I am a newbie to Linux. I tried setting environment variable using export JAVA_HOME=/usr/java/jdk1.6 but that was not permanent (i.e is was there for that terminal session). I want to know how can i set environment variable permanently in Fedora 13 just like we do in windows.After google search, some user suggested to edit bashrc and profile file for setting environment variables but above file contains some shell programs.
View 3 Replies View RelatedAfter logging in with Putty, isn't there a way to generate a GUI display?
View 1 Replies View RelatedTaking all Contacts and Emails temporarily back to Windows for safety - whilst I install Mint in place of Ubuntu. Using Thunderbird. I have checked the help files and checked Google.
View 14 Replies View RelatedI'm new to Ubuntu and I'm remote from the server. I'm setting up an Ubuntu server 10.04 x64. My intention is to load Oracle 11g, however I know I will need to be able to export an X display back to my desktop (Solaris) to run the Oracle installer. What do I need to load to get X working enough to export the display back to myself. I need to provide additional information. Since I'm new I may not have adequately covered what's needed.
View 4 Replies View RelatedI keep getting a segfault in compiz. I've tried everything! This is from a fresh install without and accelerated drivers (I have ATI)
Quote:
Code:
**Switching to Compiz window management**
/usr/local/bin/compiz-indicator:99: GtkWarning: Can't set a parent on widget which has a parent
menu.append(kill)
/usr/local/bin/compiz-indicator:100: GtkWarning: Can't set a parent on widget which has a parent
menu.append(start)
[code]....
I usually use dvgrab to make an .avi file from the video on our mini dv camcorder and save it to my pocket drive.
Right now I edit this from the pocket drive in Windows 7 on my laptop with Sony's Vegas movie studio HD 9.0 I'm having issues with the laptop lately and with out bogging down in too many details I have to burn the edited video back to the mini DV tape and transfer speeds are causing me problems.
Is there a Linux video editing software that would let me export back to the camcorder? OpenShot doesn't seem to have that option and from what I remember of PiTiVi it doesn't either.
I am happy to say that after almost a week of wandering around the INTERNET and posting desperate questions to our Ubuntu forums on how to set paths etc., I have finally begun to understand just how environment variables and path setting works. I must say, it wasn't all reading this or that, but rather making changes to my paths that helped me to understand. Anyway, if anyone who does not understand environment variables is reading this, then I recommend reading this
HTML Code:
http://java.sun.com/docs/books/tutorial/essential/environment/paths.html
and this
HTML Code:
http://www.belugalake.com/java/pathsetting.html
OK- I have 1 last question for my fellow linux users. Lets say I opened up $HOME /.profile and did some editing, and later decided to undo all of my changes but I forgot exactly what changes I made so now I want to set the default in there. How would I accomplish this? How do I set the defaults for any ~/.bashrc or ~/.cshrc type of files that I change.
seahorse export menu is always disabled. I need to export the passwords to restore it after formatting my machine.
View 1 Replies View RelatedI want to run some parts of a script in different terminals. I already found about subshell, () using parenthesis to group commands and using xterm -e (function), problem is I cannot get pid for the function running in the other terminal. And if I use & to set the job in background the terminal goes away as soon as it ends the job. I am using log files, and then send it them using built in mail. After all the parts finish I have to run the "main" script which needs the data from all the pieces. Also other question, i usually use bash, but to load a tool i need csh, the tool is not mine so i can not change the csh usage. There is anyway of passing bash scripts/commands at the moment of changing/invoking to csh shell in the same console?
View 14 Replies View RelatedI'm putting together a small bash script which uses diff in a sub shell.
RESULT=$(diff file1 file2)
This is the first time I've tried to return multiline output from a subshell - how can I get this to display as multiple lines instead of one?
I use "zip -r" to zip the following folder:
/root/Desktop/administration/backup
....My only grip is that when you open the zip file, the parent directories are there too.
So within the zip file I have to navigate through "/root/Desktop/administration" just to get to the directory called backup.
Is there a way for me to zip the directory backup, and not include the parent directories? I want to be able to open the zip file and see only the backup directory listed.
booting up my fresh re-install of 11.4 gnome from the ISO/CD, I got this in my /var/log/messages:
This is the entry point. No other messagesN files/archives exist.
Code:
Jun 13 16:33:10 linux modem-manager: (tty/ttyS0): port's parent platform driver is not whitelisted
Jun 13 16:33:10 linux modem-manager: (tty/ttyS1): port's parent platform driver is not whitelisted
[Code].....
I was reviewing some scripts written by a person that does not work with us anymore and I found a chunk of code I'd like to know more about.
Code:
mycli <<! >> /var/myprogram.log
command_1
[code]...
i've updated to oo 3.2.1 in 11.2 (64 bit) by deleting all previous oo packages and installing new. exporting (for example from draw) only gives the option of pdf. no jpeg etc.something's obviously missing but i can't find it. this has been posted back in 2009.
View 2 Replies View RelatedI am running OpenSuSE 11.3. I cannot mount an export from a Redhat 9 NFS server.I am able to mount the export from RHEL5, Ubuntu, Fedora, Solaris but not OpenSuSE 11.3. This is the command I use from a Ubuntu Karmic box.
mount server:/exportdir /mnt -o vers=3,proto=udp
As I said it works from many other distros, but not sure why no go on this one. Can anyone explain this? Should I submit a bug? I noticed portmap is not used anymore and am wondering if thatmay have anything to do with it. The rpcbind is supposed to handle this from what I read..not sure if this is accurate.
i have noticed that if vista is not the active partition, hybernate does not work. it just goes black and then back to the user icon screen to log back in. another "slight" problem was that i was not able to apply a service pack. after restoring vistas dominance i was able to install the pack. is there any other work arounds for hybernate? even though you might not be interested in cleaning up after microsoft.
View 1 Replies View RelatedI have a nfs exported filesystem but after each reboot I have to restart the NFS server twice to make it actually export the filesystem.
First restart always fails with:
Code:
Shutting down kernel based NFS server: nfsd statd mountd idmapd done
Starting kernel based NFS server: idmapdexportfs: Warning: /home/teradisk/Share does not support NFS export.
[code]...
I have a "remote" server and I want to have it's X exported to my "local" laptop. Preferably, it gets done automatically from boot. I know that virtual terminals 1-6 are all text terminals and 7 is the local X. How can I get my laptop to automatically create a virtual terminal on 12 that's dedicated to receiving the X display from the server?
I know how to get it over SSH/putty. And also how to stop the local and restart the X client on 7 to use the remote. But one of the beauties of Linux is the automation and multi-user environment. It's essentially going to act as a KVM with gui replacement over IP.
I'm using digikam 0.10.0 under openSUSE 11.2/KDE4.3. When trying to upload pictures to Flickr (i have an account and authorising the flickruploadr was successful) by using the export function I get a message saying (in German): Es ist ein Fehler aufgetreten (= error): Ungltiger Frob (=invalid frob).
- about the reason for this error
- what a frob is
- what needs to be tweaked in order to correct this
I'm running OpenSuSE 11.3 (64 bit) with the latest kernel update as of yesterday. I've recently moved from NFSv3 to NFSv4 on 4 servers. Between the 4 servers there are 9 exported directories. All of them work except 1 on 1 of the 4 servers.
/etc/exports
# NFSv4 fsid=0 for the top level directory
/export *(rw,fsid=0,async,no_subtree_check,insecure)
# End
# NFSv3
/export/apps/oracle *(rw,async,fsid=7,no_subtree_check,insecure)
/export/ftpserver *(rw,async,fsid=6,no_subtree_check,insecure)
# End
I had to keep the NFSv3 entry as I need that as the mount doesn't work with v4.
/export directory listing
/export:
total 5
drwxr-xr-x 4 root root 104 2002-08-08 16:47 .
drwxr-xr-x 33 root root 944 2011-01-25 17:28 ..
drwxr-xr-x 10 root root 232 2010-01-26 10:01 apps
drwxr-xr-x 8 root root 4096 2010-12-13 12:31 ftpserver
/export/apps:
total 0
drwxr-xr-x 10 root root 232 2010-01-26 10:01 .
drwxr-xr-x 4 root root 104 2002-08-08 16:47 ..
drwx------ 3 root root 72 2008-08-06 16:40 etc
drwxr-xr-x 2 root root 240 2011-01-24 03:00 htdig
drwx------ 3 root root 72 2008-08-06 16:40 lib
drwx------ 2 root root 48 2002-07-02 13:18 lost+found
drwxr-xr-x 4 oracle oinstall 104 2009-01-07 09:59 oracle
drwx------ 5 root root 120 2008-08-06 16:40 usr
Now on any of the 4 servers if I do:
# mount -t nfs4 machinename:/apps/oracle /mnt
mount.nfs4: mounting lister:/apps/oracle failed, reason given by server:
No such file or directory
But the other sub-dir of /export is fine:
# mount -t nfs4 machinename:/apps/ftpserver /mnt
If I mount the pseudo root:
# mount -t nfs4 machinename:/ /mnt
# ls -l /mnt
total 4
drwxr-xr-x 2 root root 48 2002-08-08 15:20 apps
drwxr-xr-x 8 root root 4096 2010-12-13 12:31 ftpserver
But the apps sub-dir is empty
# ls -l /mnt/apps
total 0
On the server:
# ls -l /export/apps
total 0
drwx------ 3 root root 72 2008-08-06 16:40 etc
drwxr-xr-x 2 root root 240 2011-01-24 03:00 htdig
drwx------ 3 root root 72 2008-08-06 16:40 lib
drwx------ 2 root root 48 2002-07-02 13:18 lost+found
drwxr-xr-x 4 oracle oinstall 104 2009-01-07 09:59 oracle
drwx------ 5 root root 120 2008-08-06 16:40 usr
Well that explains why the NFSv4 mount of /apps/oracle fails because for some reason it can't "see" any files below that, but as I say the ftpserver sub-dir & mount are fine.
I'm trying to read content of file to variable and use this variable in for loop. The problem is, when I have c++ comment style in file - /*. Spaces in line are also interpreted as separated lines.
For example:
Code:
Changing $files to "$files" eliminate these problems but causes that whole content of variable is treated as one string (one execution of loop).
how to assign a local variable value to a global variable....
View 2 Replies View Relatedmy script has a variable which comes in the form +00.00 +0.00 -00.00 or -0.00 (the numbers can be any in that form) for any that have a + symbol I need to remove the +, but if it has a - symbol it needs to stay.
i need to make a new variable with the string from the old variable btut without any plus sign. I have tried a lot of different ways with no success, each thing I tried either left the + or removed the entire string. I think this should work but doesn't
foo=+12.40
bar=${foo#+}
I am supposed to create an environment variable with the PRINTER variable, which should resolve to the word sales. Would the command be like this?: env PRINTER - NAME=SALES (is this the command to create that variable with resolving the word sales to it?)
View 3 Replies View RelatedI have a text file i that has a mailTo: NAME in it. In a bash script i need to extract NAME and put it in a $variable to use. How do i do this?
View 2 Replies View Related