running commands from script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting running commands from script
# 1  
Old 01-04-2006
Question running dirs command from script

I'm new to unix and I have a fairly simple problem:

Lets say I am in a specific directory and I run the command: "dirs" ,

I get an output of all the folders that i pushed into the stack (as expected),
buut,
when when I create a script (called test):
Code:
#! /bin/csh

dirs

and then i run: ./test

It outputs only the last directory that I pushed into the stack (as opposed to the whole stack).For some reason the Script does'nt recognize the stack that I have in the prompt.

whyyy?? Pleeaase help

Last edited by owijust; 01-04-2006 at 03:45 PM..
# 2  
Old 01-05-2006
I think that when you run the script, you are creating a new process for which the directory stack is empty. Try using pushd in the script before you run the 'dirs' command.
# 3  
Old 01-09-2006
Java VI Programming

I am new to Linux. I am tring to write a bash shell script. Can someone tell me the proper steps input data to "VI" so that I can execute my script.

Thank In Advance.

Last edited by Gotrain; 01-09-2006 at 07:48 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl script running multiple commands at once

Hi All, I have put a perl script together to go and collect some information from multiple nodes/endpoints. The script works absolutly fine however I want to make it quicker. You will see in the below that my script calls an expect script called ssh_run_cmd2.exp followed by the IP of... (7 Replies)
Discussion started by: mutley2202
7 Replies

2. Shell Programming and Scripting

Running set of commands in remote servers in shell script

Hi Wishing to all. I am very new joined in an organization as a unix system administrator. I need a help in preparing a script for a report. i have a file contains all of the linux/ubuntu servers line by line around 140 servers. vi servers.txt nh01 nh02 nh03 bh01 bh04 - - :wq (3 Replies)
Discussion started by: kumaraswamy
3 Replies

3. Shell Programming and Scripting

Issue with running commands from shell script

I'm trying to copy files from a remote windows server to Unix server. I was successfully able to copy files from windows server using command prompt but when I run these commands from a script it's not working as expected. commands used: sftp user@remoteserver.com lcd local_dir cd... (3 Replies)
Discussion started by: naresh7590
3 Replies

4. Shell Programming and Scripting

Running script and commands through SSH

Hello All, I am trying to run some simulations through SSH from my mac on our university SOLARIS system. My problem is that whenever I want to execute a command I get an error which says "Invalid argument". Maybe I should explain more what I want to do and what I did. Firstly I installed a... (10 Replies)
Discussion started by: Apfik
10 Replies

5. Shell Programming and Scripting

Simple script editing text files and running commands

Okay this will probably have multiple parts to it but I don't really want to trouble you guys with more help because I'm a total noob so I can just do the first part by hand (it's just editing a few hundred lines of text in a file; I have to do the same thing on each line and I'm sure there's a... (2 Replies)
Discussion started by: guitarscn
2 Replies

6. Shell Programming and Scripting

Alert for long running commands in script

Hi All, Is there a way in which a long running command can terminate by itself inside a script? I need something like below: echo Start <command> exit If the <command> is taking more than say 100 seconds to complete, the script should exit without manual intervention. Thanks, Deepak (2 Replies)
Discussion started by: deepakgang
2 Replies

7. Shell Programming and Scripting

Running unix commands in a perl script

Executing two unix commads via perl script one after another e.g: make clean bsub -i -q short make have tried using exec but the second command doesnt executes (1 Reply)
Discussion started by: rajroshan
1 Replies

8. Shell Programming and Scripting

Running multiple unix commands in a single script

Hi, I would like to write a script with include more than 6 unix commands. my script like below: echo " script started" ls -ld bdf | grep "rama" tail -10 log.txt ... .. ... now, i want to run above unix commands one by one. example: first the ls -ld command will be... (3 Replies)
Discussion started by: koti_rama
3 Replies

9. UNIX for Dummies Questions & Answers

running a simple script file with multiple commands

I'm trying to run a script file with multiple commands that I would normally type into the command line. The commands are: #!/bin/bash diff Test1.o0 /usr3/ronelso4/Desktop/verificationKPC/Test1.o0 > differences2 diff Test1a.o0 /usr3/ronelso4/Desktop/verificationKPC/Test1a.o0 >> differences2... (1 Reply)
Discussion started by: knelson
1 Replies

10. Shell Programming and Scripting

running script in cron - with ssh commands - not working

I ran an ssh command to run a script on a remote server ssh -l <user> <servername> /path/to/script/scriptname This works fine - and the script is executed correctly. However - I put this command into a script, that I want to run from cron every hour, to execute the file on the remote... (31 Replies)
Discussion started by: frustrated1
31 Replies
Login or Register to Ask a Question