You are not logged in.
I need a script to do this:
launch a terminal, from this change working directory and then launch a command; the terminal have to remain opened after the command execution.
Something like:
$terminal cd $dir && $command
If I open a terminal and I do:
cd $dir && $command
it works
If I do a .sh script with this:
xterm -hold -e cd $dir && $command
or
terminal -H -x cd $dir && $command
when I launch it (the script) it doesn't work.
Last edited by buntolo (2012-01-05 23:44:52)
Offline
You can run
xterm -hold -e /path/to/app
the $app being a script
[karol@black ~]$ cat app
#!/bin/bash
cd ~/test/ && ls
Last edited by karol (2012-01-05 23:55:42)
Offline
You can run
xterm -hold -e /path/to/app
the $app being a script.
It doesn't work.
That application check if it has already been installed in her actual directory.
In that way the working directory (pwd) will remain the one where the script is and so the application will think it has never been installed and start to install herself again in the directory where the script resides.
EDIT:
You can run
xterm -hold -e /path/to/app
the $app being a script
[karol@black ~]$ cat app #!/bin/bash cd ~/test/ && ls
What ls stand for?
Not the list command?
Anyway you've got me this idea:
script: it will launch another script which already is in the right directory and this last one will launch terminal with command in.
Last edited by buntolo (2012-01-06 00:02:50)
Offline
xterm -hold -e "cd ~/test/ && ls"
works too.
I don't know what $command do you mean, but this will list th ~/test directory.
Offline
Why can't you just have
cd $dir
as the first line of your script?
Offline
Why can't you just have
cd $dir
as the first line of your script?
It doesn't work.
That application check if it has already been installed in her actual directory.
In that way the working directory (pwd) will change only for "cd $dir", then the terminal with the $command will open in the script directory and NOT in "cd $dir"; in this way the application will fail the check and proceed to install in the script-dir.
Offline
xterm -hold -e "cd ~/test/ && ls"
works too.
I don't know what $command do you mean, but this will list th ~/test directory.
It works also for me.
With urxvt and xfce4-terminal don't work.
But xterm is too minimalist, is there an advanced terminal based on it?
And I don't unerstand why it doesn't work for xfce4-terminal but for it does for xterm...
man xfce4-terminal:
-H, --hold
Causes the terminal to be kept around after the child command has terminated
-e, --command=command
Execute command inside the terminal
man xterm:
-hold
Turn on the hold resource, i.e., xterm will not immediately destroy its window when the shell command completes. It will wait until you use the window manager to destroy/kill the window, or if you use the menu entries that send a signal, e.g., HUP or KILL.
-e program [ arguments ... ]
This option specifies the program (and its command line arguments) to be run in the xterm window. It also sets the window title and icon name to be the basename of the program being executed if neither -T nor -n are given on the command line. This must be the last option on the command line.
What the ...?
Is only my opinion that there aren't differences between:
terminal -H -e "cd $dir && $command"
and
xterm -hold -e "cd $dir && $command"
???
Last edited by buntolo (2012-01-06 13:11:58)
Offline
The man page for urxvt explains what to do for execute. hold will work with this:
-e command [arguments]
Run the command with its command-line arguments in the urxvt window; also sets the window title and icon name to be the basename
of the program being executed if neither -title (-T) nor -n are given on the command line. If this option is used, it must be
the last on the command-line. If there is no -e option then the default is to run the program specified by the SHELL environment
variable or, failing that, sh(1).
Please note that you must specify a program with arguments. If you want to run shell commands, you have to specify the shell,
like this:
urxvt -e sh -c "shell commands"
Offline
If urxvt is run w/o 'sh -c', it throws 'urxvt: unable to exec child.' error. Is Terminal printing any errors?
Offline
I just tried this in XFCE's terminal and it works fine:
terminal -e ls --hold
Offline
I just tried this in XFCE's terminal and it works fine:
terminal -e ls --hold
Just out of curiosity, what does the '-x' switch do?
Offline