Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

The University of California Statistics Department; where mean is normal, and deviation standard.


devel / comp.unix.shell / Re: perl open shell and linux commands

SubjectAuthor
* Re: perl open shell and linux commandsJavier
`* Re: perl open shell and linux commandsJavier
 `- Re: perl open shell and linux commandsJavier

1
Re: perl open shell and linux commands

<jvCdnRzEhsNBliz9nZ2dnUU78cPNnZ2d@brightview.co.uk>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=3874&group=comp.unix.shell#3874

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!ecngs!feeder2.ecngs.de!37.252.120.71.MISMATCH!2.eu.feeder.erje.net!feeder.erje.net!border1.nntp.ams1.giganews.com!nntp.giganews.com!buffer1.nntp.ams1.giganews.com!nntp.brightview.co.uk!news.brightview.co.uk.POSTED!not-for-mail
NNTP-Posting-Date: Fri, 28 May 2021 10:27:24 -0500
From: inva...@invalid.invalid (Javier)
Subject: Re: perl open shell and linux commands
Newsgroups: comp.unix.shell
References: <fafb1b32-faaa-49ad-965c-eef1fe6b4a3an@googlegroups.com>
Message-ID: <jvCdnRzEhsNBliz9nZ2dnUU78cPNnZ2d@brightview.co.uk>
Date: Fri, 28 May 2021 10:27:24 -0500
Lines: 31
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-NyqRUTr2FEk6f4xYBttMlMXp+FAmtT0lz+UopEN3Bw4vcyHWs5XftX8CuvZyjPbyyrCGZLtWp9QqKFe!YMQP7Hoj/cHRoYY2v1JBag4ZniDOUjEll3q9lQo/q0Uerf77Rqqhs4yzWjx/gc7qeAU/68S32lKG!WkN5nS4daaAjfMNRGmua7jm3zYk=
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Original-Bytes: 2301
 by: Javier - Fri, 28 May 2021 15:27 UTC

ej...@pacbell.net <ejm20@pacbell.net> wrote:

> Ive been asked to create a perl script in bash that will open an
> xterm or terminal, cd to a specific directory, the load modules. I
> have very little perl experience and have been searching the web and
> books with no luck. I can get it to open the shell with the env/paths
> but cant execute any commands like a simple "cd". Heres what I got:
>
> #!/usr/bin/perl
>
> system ('gnome-terminal', 'sh', -c 'cd /home/$USER/projects; module load project/test' );
>

It's not very clear what you want to do exactly, but all languages
have a feature to execute commands at interpreter startup befaure it
goes into interactive. In bash it's done with --rcfile (the -c option
in your post will not go into interactive)

#!/usr/bin/perl
system ('gnome-terminal','--', 'bash --rcfile <(echo "cd /home/$USER/projects;
module load project/test;" )');

Note that I use bash instead of sh to use the bash feature of process
substitution <(...) to avoiding creating an extra file. I'm almost
sure it will work, because if your system has gnome-terminal
installed, there is a >99% probability that bash is also there.

PS: what you want to do is a bad praxis because it hides the
environment setup from the users and they will not be able to replicate
the environment setup should they want to do the same thing in their
own scripts.

Re: perl open shell and linux commands

<HuudnSMVk-4fpyz9nZ2dnUU78UudnZ2d@brightview.co.uk>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=3881&group=comp.unix.shell#3881

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!border2.nntp.ams1.giganews.com!nntp.giganews.com!buffer2.nntp.ams1.giganews.com!nntp.brightview.co.uk!news.brightview.co.uk.POSTED!not-for-mail
NNTP-Posting-Date: Fri, 28 May 2021 13:46:26 -0500
From: inva...@invalid.invalid (Javier)
Subject: Re: perl open shell and linux commands
Newsgroups: comp.unix.shell
References: <fafb1b32-faaa-49ad-965c-eef1fe6b4a3an@googlegroups.com> <jvCdnRzEhsNBliz9nZ2dnUU78cPNnZ2d@brightview.co.uk>
Message-ID: <HuudnSMVk-4fpyz9nZ2dnUU78UudnZ2d@brightview.co.uk>
Date: Fri, 28 May 2021 13:46:26 -0500
Lines: 14
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-6IQOkfgGaCZN/Uf3//onsaVSOJRmRe/JLbCdnTl/A/qCHYF8kHLYsoZuCyeamsnJAugpzDfyZhcRQ4c!jj/ptFMwfhmlzdhg3BFshOYRjlgtyJpHpHSdo3psVGccbRZ3HafB+3yWrMdaZgd4tNbT5lrtalDg!8wBmXkxte7gCyYY6HNvBOx4cBWg=
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Original-Bytes: 1373
 by: Javier - Fri, 28 May 2021 18:46 UTC

Javier <invalid@invalid.invalid> wrote:
>
> #!/usr/bin/perl
> system ('gnome-terminal','--', 'bash --rcfile <(echo "cd /home/$USER/projects;
> module load project/test;" )');
>

Since the OP asks in the other subthread about xterm, this is the xterm version.
Just tested and works fine for me.

#!/usr/bin/perl
system ('xterm','-e', 'bash --rcfile <(echo "cd /home/$USER;
module load project/test;" )');

Re: perl open shell and linux commands

<69adnRA6EPTE3iz9nZ2dnUU78enNnZ2d@brightview.co.uk>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=3884&group=comp.unix.shell#3884

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!buffer1.nntp.ams1.giganews.com!nntp.brightview.co.uk!news.brightview.co.uk.POSTED!not-for-mail
NNTP-Posting-Date: Fri, 28 May 2021 14:24:09 -0500
From: inva...@invalid.invalid (Javier)
Subject: Re: perl open shell and linux commands
Newsgroups: comp.unix.shell
References: <fafb1b32-faaa-49ad-965c-eef1fe6b4a3an@googlegroups.com> <jvCdnRzEhsNBliz9nZ2dnUU78cPNnZ2d@brightview.co.uk> <HuudnSMVk-4fpyz9nZ2dnUU78UudnZ2d@brightview.co.uk> <0c307c6a-c247-4238-a92c-c4af4e651a18n@googlegroups.com>
Message-ID: <69adnRA6EPTE3iz9nZ2dnUU78enNnZ2d@brightview.co.uk>
Date: Fri, 28 May 2021 14:24:09 -0500
Lines: 12
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-85u2UgrXPboBv/1h6Yhfbr1t36ZVP2jp1V1aeJ6XVNKEntxJgsA3sv5GnxyCFPCiFmOe7vnDDYm7OUy!iJvbyER4XgR9vivmsrhkSkuiEP+Py7nNVyrz7RYiegnBrwkeTXNq4bg8bfM2yUC0P06a6xXBxzjz!9J6MJz8aAaBZliu7ZSvQIznzgYI=
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Original-Bytes: 1432
 by: Javier - Fri, 28 May 2021 19:24 UTC

ej...@pacbell.net <ejm20@pacbell.net> wrote:
> the xterm example does open an xterm and cd's but does not load the .bashrc.

Yes, when using the --rcfile option you need to include the bashrc
sourcing explicitely in your own rc file.

#!/usr/bin/perl
system ('xterm','-e', 'bash --rcfile <(echo ". cd /home/$USER;
.. /home/$USER/.bashrc;
module load project/test;" )');

1
server_pubkey.txt

rocksolid light 0.9.7
clearnet tor