last day (15 days later) » 

17:12
@terdon gotcha. Well, I ran that script through and got/global/homes/j/jclassqk/exe/submitscript: line 2: cd: s1975: No such file or directory
/global/homes/j/jclassqk/exe/submitscript: line 2: cd: s1976: No such file or directory
/global/homes/j/jclassqk/exe/submitscript: line 2: cd: s1977: No such file or directory
/global/homes/j/jclassqk/exe/submitscript: line 2: cd: s1978: No such file or directory
/global/homes/j/jclassqk/exe/submitscript: line 2: cd: s1979: No such file or directory
/global/homes/j/jclassqk/exe/submitscript: line 2: cd: s1980: No such file or directory
@jcklasseter Show me the exact command you ran please.
@terdon for dir in s{0001..2000}; do
cd "$dir" && echo hello world >> ~/bin/log.txt; cd ../
done
echo WITH GREAT SUBMISSION COMES GREAT RESPONSIBILITY
@jcklasseter Actually, let's take this to another room. Join me here please.
Hey!
for dir in s{0001..2000}; do
cd "$dir" && echo hello world >> ~/bin/log.txt; cd ../
done
echo WITH GREAT SUBMISSION COMES GREAT RESPONSIBILITY
4 messages moved from Ask Ubuntu General Room
OK, so where's the command?
All you're doing is echoing
@jcklasseter?
17:22
I have it in my path as submitscript. I type submit script, and get the messages above. I tried from the parent directory as well as from inside the child. Yeah, but is it not a valid test to see if the writing to the log works?
submitscript is one word, but on a mac it likes to autocorrect in safari
@jcklasseter Indeed it is, OK
mac! Oh
ah, but no, the expansion worked
Well, I'm shed into another computer running linux.
Where are you running it from? When you say parent dir, you mean the one that contains all the sNNN ones right?
I'm also testing it there.
Yes the parent has s0001....
and so forth
OK. Try this. Go into the parent directory and just run for d in s{0001..0004}; do ls -ld "$d"; done
17:24
Ive tried it where ls brings up 2000 folders, and I've tried it inside one of the folders.
It should always be run from the directory that contains the sNNN folders.
As a script or can I copy-paste?
@jcklasseter Copy paste
for d in s{0001..0004}; do ls -ld "$d"; done
I did and
hopper06 test/scripttest> for d in s{0001..0004}; do ls -ld "$d"; done

CORRECT>for d in s{0001..0004}; od ls -ld "$d"; done (y|n|e|a)? no
for: Command not found.
d: Undefined variable.
hopper06 test/scripttest> for d in s{0001..0004}; do ls -ld "$d"; done

CORRECT>for d in s{0001..0004}; od ls -ld "$d"; done (y|n|e|a)? yes
for: Command not found.
d: Undefined variable.
What is that?
What's CORRECT> ?
That's not bash
@jcklasseter?
17:30
Shit. The default environment got changed to csh. Sorry. Not my computer. Let me try it now that that's fixed
Ah, yes, that would explain it.
It would, wouldn't it
:)
Not the original error though.
Gave me the same error. What's the command to check shell? maybe it's not kicked in yet.
@jcklasseter ps -p $$
To switch to bash, just run bash from the csh prompt
Oh, Ask Ubuntu is very strict on its on-topic policy. It sounds like you're not running Ubuntu but another distro or OSX. Next time, don't ask there, go to Unix & Linux instead.
17:35
Gotcha. Sorry. But the command worked and gave me
ls: cannot access s1: No such file or directory
ls: cannot access s2: No such file or directory
ls: cannot access s3: No such file or directory
ls: cannot access s4: No such file or directory
"worked"
Ah! Old bash version, I think. What does echo {001..005} print?
The right thing.
Including the leading 0s?
Yeah. It very well could be an old bash. Do you know of the NERSC computers? Blame them.
No. Just the didgets
@jcklasseter That's the problem
17:38
Would make sense.
OK, what exactly is this machine you're on? Is it Linux or UNIX? Which Linux?
Sorry for the trouble. I do appreciate the help. It's the cray linux environment.
Oh, OK, don't even know what that is. Hang on, figuring out a workaround
Thanks.
@jcklasseter try this:
seq 1 5 | while read i; do
    dir=$(printf '%0.4d\n' "$i")
    echo "cd $dir && run_program; cd ../;"
done
Paste the output here
17:45
Should I change the run_program part?
@jcklasseter Nah, that just prints it out, it won't run it
I just want to make sure that the right directories are shown
Actually, run this one instead:
seq 1 5 | while read i; do
    dir=$(printf '%0.4d\n' "$i")
    ls -ld "$dir"
done
@jcklasseter ^^
got it
ls: cannot access 0001: No such file or directory
ls: cannot access 0002: No such file or directory
ls: cannot access 0003: No such file or directory
ls: cannot access 0004: No such file or directory
ls: cannot access 0005: No such file or directory
WITH GREAT SUBMISSION COMES GREAT RESPONSIBILITY
jclassqk@hopper06:~/bin/test/scripttest>
Ignore my little echo at the end of the script. It was already there
Sorry, I'm an idiot, forgot the s
seq 1 5 | while read i; do
    dir=$(printf '%0.4d\n' "$i")
    ls -ld s"$dir"
done
ITs okay. I wasn't sure how to add ir
simple enough
Sometimes it is, yes :)
17:52
jclassqk@hopper06:~/bin/test/scripttest> ~/exe/submitscript
drwxr-x--- 2 jclassqk jclassqk 512 Jun 8 08:39 s0001
drwxr-x--- 2 jclassqk jclassqk 512 Jun 8 08:39 s0002
drwxr-x--- 2 jclassqk jclassqk 512 Jun 8 08:39 s0003
drwxr-x--- 2 jclassqk jclassqk 512 Jun 8 08:39 s0004
drwxr-x--- 2 jclassqk jclassqk 512 Jun 8 08:39 s0005
WITH GREAT SUBMISSION COMES GREAT RESPONSIBILITY
jclassqk@hopper06:~/bin/test/scripttest>
there we go
Perfect
Then see my updated answer, that should work:
seq 1 2000 | while read i; do
   dir=$(printf '%0.4d\n' "$i")
   cd s"$dir" && run_program; cd ../;
done
Or:
And I just change the run_programs to command >> log.txt?
seq 1 2000 | while read i; do
   dir=$(printf '%0.4d\n' "$i")
   cd s"$dir" && echo hello world >> ~/bin/log.txt;
  cd ../ ;
done
@jcklasseter Yes, exactly.
Perfect log of 2000 hellos. Thanks a bunch man!
@jcklasseter Great! You're welcome.
Seriously though, next time ask on Unix & Linux. There are way more CLI junkies there and Ask Ubuntu is for Ubuntu only. We deal with any *nix on U&L.

  last day (15 days later) »